@@ -3635,6 +3635,97 @@ private Map<String, Long> getProcessIdTag() {
3635
3635
return Collections .singletonMap (PID_TAG , getProcessId ());
3636
3636
}
3637
3637
3638
+ private Map <String , String > getAzureAppServicesTags () {
3639
+ // These variable names and derivations are copied from the dotnet tracer
3640
+ // See
3641
+ // https://github.com/DataDog/dd-trace-dotnet/blob/master/tracer/src/Datadog.Trace/PlatformHelpers/AzureAppServices.cs
3642
+ // and
3643
+ // https://github.com/DataDog/dd-trace-dotnet/blob/master/tracer/src/Datadog.Trace/TraceContext.cs#L207
3644
+ Map <String , String > aasTags = new HashMap <>();
3645
+
3646
+ /// The site name of the site instance in Azure where the traced application is running.
3647
+ String siteName = getEnv ("WEBSITE_SITE_NAME" );
3648
+ if (siteName != null ) {
3649
+ aasTags .put ("aas.site.name" , siteName );
3650
+ }
3651
+
3652
+ // The kind of application instance running in Azure.
3653
+ // Possible values: app, api, mobileapp, app_linux, app_linux_container, functionapp,
3654
+ // functionapp_linux, functionapp_linux_container
3655
+
3656
+ // The type of application instance running in Azure.
3657
+ // Possible values: app, function
3658
+ if (getEnv ("FUNCTIONS_WORKER_RUNTIME" ) != null
3659
+ || getEnv ("FUNCTIONS_EXTENSIONS_VERSION" ) != null ) {
3660
+ aasTags .put ("aas.site.kind" , "functionapp" );
3661
+ aasTags .put ("aas.site.type" , "function" );
3662
+ } else {
3663
+ aasTags .put ("aas.site.kind" , "app" );
3664
+ aasTags .put ("aas.site.type" , "app" );
3665
+ }
3666
+
3667
+ // The resource group of the site instance in Azure App Services
3668
+ String resourceGroup = getEnv ("WEBSITE_RESOURCE_GROUP" );
3669
+ if (resourceGroup != null ) {
3670
+ aasTags .put ("aas.resource.group" , resourceGroup );
3671
+ }
3672
+
3673
+ // Example: 8c500027-5f00-400e-8f00-60000000000f+apm-dotnet-EastUSwebspace
3674
+ // Format: {subscriptionId}+{planResourceGroup}-{hostedInRegion}
3675
+ String websiteOwner = getEnv ("WEBSITE_OWNER_NAME" );
3676
+ int plusIndex = websiteOwner == null ? -1 : websiteOwner .indexOf ("+" );
3677
+
3678
+ // The subscription ID of the site instance in Azure App Services
3679
+ String subscriptionId = null ;
3680
+ if (plusIndex > 0 ) {
3681
+ subscriptionId = websiteOwner .substring (0 , plusIndex );
3682
+ aasTags .put ("aas.subscription.id" , subscriptionId );
3683
+ }
3684
+
3685
+ if (subscriptionId != null && siteName != null && resourceGroup != null ) {
3686
+ // The resource ID of the site instance in Azure App Services
3687
+ String resourceId =
3688
+ "/subscriptions/"
3689
+ + subscriptionId
3690
+ + "/resourcegroups/"
3691
+ + resourceGroup
3692
+ + "/providers/microsoft.web/sites/"
3693
+ + siteName ;
3694
+ resourceId = resourceId .toLowerCase (Locale .ROOT );
3695
+ aasTags .put ("aas.resource.id" , resourceId );
3696
+ } else {
3697
+ log .warn (
3698
+ "Unable to generate resource id subscription id: {}, site name: {}, resource group {}" ,
3699
+ subscriptionId ,
3700
+ siteName ,
3701
+ resourceGroup );
3702
+ }
3703
+
3704
+ // The instance ID in Azure
3705
+ String instanceId = getEnv ("WEBSITE_INSTANCE_ID" );
3706
+ instanceId = instanceId == null ? "unknown" : instanceId ;
3707
+ aasTags .put ("aas.environment.instance_id" , instanceId );
3708
+
3709
+ // The instance name in Azure
3710
+ String instanceName = getEnv ("COMPUTERNAME" );
3711
+ instanceName = instanceName == null ? "unknown" : instanceName ;
3712
+ aasTags .put ("aas.environment.instance_name" , instanceName );
3713
+
3714
+ // The operating system in Azure
3715
+ String operatingSystem = getEnv ("WEBSITE_OS" );
3716
+ operatingSystem = operatingSystem == null ? "unknown" : operatingSystem ;
3717
+ aasTags .put ("aas.environment.os" , operatingSystem );
3718
+
3719
+ // The version of the extension installed
3720
+ String siteExtensionVersion = getEnv ("DD_AAS_JAVA_EXTENSION_VERSION" );
3721
+ siteExtensionVersion = siteExtensionVersion == null ? "unknown" : siteExtensionVersion ;
3722
+ aasTags .put ("aas.environment.extension_version" , siteExtensionVersion );
3723
+
3724
+ aasTags .put ("aas.environment.runtime" , getProp ("java.vm.name" , "unknown" ));
3725
+
3726
+ return aasTags ;
3727
+ }
3728
+
3638
3729
private int schemaVersionFromConfig () {
3639
3730
String versionStr =
3640
3731
configProvider .getString (TRACE_SPAN_ATTRIBUTE_SCHEMA , "v" + SpanNaming .SCHEMA_MIN_VERSION );
@@ -3856,97 +3947,6 @@ public boolean isTelemetryDebugRequestsEnabled() {
3856
3947
return telemetryDebugRequestsEnabled ;
3857
3948
}
3858
3949
3859
- private Map <String , String > getAzureAppServicesTags () {
3860
- // These variable names and derivations are copied from the dotnet tracer
3861
- // See
3862
- // https://github.com/DataDog/dd-trace-dotnet/blob/master/tracer/src/Datadog.Trace/PlatformHelpers/AzureAppServices.cs
3863
- // and
3864
- // https://github.com/DataDog/dd-trace-dotnet/blob/master/tracer/src/Datadog.Trace/TraceContext.cs#L207
3865
- Map <String , String > aasTags = new HashMap <>();
3866
-
3867
- /// The site name of the site instance in Azure where the traced application is running.
3868
- String siteName = getEnv ("WEBSITE_SITE_NAME" );
3869
- if (siteName != null ) {
3870
- aasTags .put ("aas.site.name" , siteName );
3871
- }
3872
-
3873
- // The kind of application instance running in Azure.
3874
- // Possible values: app, api, mobileapp, app_linux, app_linux_container, functionapp,
3875
- // functionapp_linux, functionapp_linux_container
3876
-
3877
- // The type of application instance running in Azure.
3878
- // Possible values: app, function
3879
- if (getEnv ("FUNCTIONS_WORKER_RUNTIME" ) != null
3880
- || getEnv ("FUNCTIONS_EXTENSIONS_VERSION" ) != null ) {
3881
- aasTags .put ("aas.site.kind" , "functionapp" );
3882
- aasTags .put ("aas.site.type" , "function" );
3883
- } else {
3884
- aasTags .put ("aas.site.kind" , "app" );
3885
- aasTags .put ("aas.site.type" , "app" );
3886
- }
3887
-
3888
- // The resource group of the site instance in Azure App Services
3889
- String resourceGroup = getEnv ("WEBSITE_RESOURCE_GROUP" );
3890
- if (resourceGroup != null ) {
3891
- aasTags .put ("aas.resource.group" , resourceGroup );
3892
- }
3893
-
3894
- // Example: 8c500027-5f00-400e-8f00-60000000000f+apm-dotnet-EastUSwebspace
3895
- // Format: {subscriptionId}+{planResourceGroup}-{hostedInRegion}
3896
- String websiteOwner = getEnv ("WEBSITE_OWNER_NAME" );
3897
- int plusIndex = websiteOwner == null ? -1 : websiteOwner .indexOf ('+' );
3898
-
3899
- // The subscription ID of the site instance in Azure App Services
3900
- String subscriptionId = null ;
3901
- if (plusIndex > 0 ) {
3902
- subscriptionId = websiteOwner .substring (0 , plusIndex );
3903
- aasTags .put ("aas.subscription.id" , subscriptionId );
3904
- }
3905
-
3906
- if (subscriptionId != null && siteName != null && resourceGroup != null ) {
3907
- // The resource ID of the site instance in Azure App Services
3908
- String resourceId =
3909
- "/subscriptions/"
3910
- + subscriptionId
3911
- + "/resourcegroups/"
3912
- + resourceGroup
3913
- + "/providers/microsoft.web/sites/"
3914
- + siteName ;
3915
- resourceId = resourceId .toLowerCase (Locale .ROOT );
3916
- aasTags .put ("aas.resource.id" , resourceId );
3917
- } else {
3918
- log .warn (
3919
- "Unable to generate resource id subscription id: {}, site name: {}, resource group {}" ,
3920
- subscriptionId ,
3921
- siteName ,
3922
- resourceGroup );
3923
- }
3924
-
3925
- // The instance ID in Azure
3926
- String instanceId = getEnv ("WEBSITE_INSTANCE_ID" );
3927
- instanceId = instanceId == null ? "unknown" : instanceId ;
3928
- aasTags .put ("aas.environment.instance_id" , instanceId );
3929
-
3930
- // The instance name in Azure
3931
- String instanceName = getEnv ("COMPUTERNAME" );
3932
- instanceName = instanceName == null ? "unknown" : instanceName ;
3933
- aasTags .put ("aas.environment.instance_name" , instanceName );
3934
-
3935
- // The operating system in Azure
3936
- String operatingSystem = getEnv ("WEBSITE_OS" );
3937
- operatingSystem = operatingSystem == null ? "unknown" : operatingSystem ;
3938
- aasTags .put ("aas.environment.os" , operatingSystem );
3939
-
3940
- // The version of the extension installed
3941
- String siteExtensionVersion = getEnv ("DD_AAS_JAVA_EXTENSION_VERSION" );
3942
- siteExtensionVersion = siteExtensionVersion == null ? "unknown" : siteExtensionVersion ;
3943
- aasTags .put ("aas.environment.extension_version" , siteExtensionVersion );
3944
-
3945
- aasTags .put ("aas.environment.runtime" , getProp ("java.vm.name" , "unknown" ));
3946
-
3947
- return aasTags ;
3948
- }
3949
-
3950
3950
public boolean isAgentlessLogSubmissionEnabled () {
3951
3951
return agentlessLogSubmissionEnabled ;
3952
3952
}
0 commit comments