示例#1
0
        public Scope CreateScope(OutboundHttpArgs args, out HttpTags tags)
        {
            tags = new DatadogHttpTags();
            var requestUri = args.RequestUri;
            var httpMethod = args.HttpMethod;

            string serviceName = _tracer.Settings.GetServiceName(_tracer, "http-client");
            var    scope       = _tracer.StartActiveWithTags("http.request", tags: tags, serviceName: serviceName, spanId: args.SpanId);

            scope.Span.Type = SpanTypes.Http;

            tags.HttpMethod = httpMethod;
            tags.HttpUrl    = UriHelpers.CleanUri(requestUri, removeScheme: false, tryRemoveIds: false);
            string resourceUrl = UriHelpers.CleanUri(requestUri, removeScheme: true, tryRemoveIds: true);

            scope.Span.ResourceName = $"{httpMethod} {resourceUrl}";

            var integrationId = args.IntegrationInfo;

            tags.InstrumentationName = IntegrationRegistry.GetName(integrationId);
            tags.SetAnalyticsSampleRate(integrationId, _tracer.Settings, enabledWithGlobalSetting: false);
            return(scope);
        }
示例#2
0
        public void CleanUri_HttpUrlTag(string uri, string expected)
        {
            string actual = UriHelpers.CleanUri(new Uri(uri), removeScheme: false, tryRemoveIds: false);

            Assert.Equal(expected, actual);
        }
示例#3
0
        public void CleanUri_ResourceName(string uri, string expected)
        {
            string actual = UriHelpers.CleanUri(new Uri(uri), removeScheme: true, tryRemoveIds: true);

            Assert.Equal(expected, actual);
        }