report "interpreter" version (#459)
* add constant for http header "Datadog-Meta-Lang-Version" * split framework description into interpreter and version * place managed assembly version into a local variable * save tracer version and framework name and version into static readonly variables * no need to keep the strings around in static vars since the HttpClient (and its headers) are kept around forever
This commit is contained in:
parent
6695c50baf
commit
16e6a50cd8
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Http;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading.Tasks;
|
||||
using Datadog.Trace.Logging;
|
||||
|
|
@ -39,10 +40,13 @@ namespace Datadog.Trace.Agent
|
|||
|
||||
_tracesEndpoint = new Uri(baseEndpoint, TracesPath);
|
||||
|
||||
// TODO:bertrand add header for os version
|
||||
GetFrameworkDescription(out string frameworkName, out string frameworkVersion);
|
||||
var tracerVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString();
|
||||
|
||||
_client.DefaultRequestHeaders.Add(AgentHttpHeaderNames.Language, ".NET");
|
||||
_client.DefaultRequestHeaders.Add(AgentHttpHeaderNames.LanguageInterpreter, RuntimeInformation.FrameworkDescription);
|
||||
_client.DefaultRequestHeaders.Add(AgentHttpHeaderNames.TracerVersion, this.GetType().Assembly.GetName().Version.ToString());
|
||||
_client.DefaultRequestHeaders.Add(AgentHttpHeaderNames.LanguageInterpreter, frameworkName);
|
||||
_client.DefaultRequestHeaders.Add(AgentHttpHeaderNames.LanguageVersion, frameworkVersion);
|
||||
_client.DefaultRequestHeaders.Add(AgentHttpHeaderNames.TracerVersion, tracerVersion);
|
||||
|
||||
// don't add automatic instrumentation to requests from this HttpClient
|
||||
_client.DefaultRequestHeaders.Add(HttpHeaderNames.TracingEnabled, "false");
|
||||
|
|
@ -104,6 +108,20 @@ namespace Datadog.Trace.Agent
|
|||
}
|
||||
}
|
||||
|
||||
private static void GetFrameworkDescription(out string name, out string version)
|
||||
{
|
||||
// RuntimeInformation.FrameworkDescription returns string like ".NET Framework 4.7.2" or ".NET Core 2.1",
|
||||
// we want to split the runtime from the version so we can report them as separate values
|
||||
string frameworkDescription = RuntimeInformation.FrameworkDescription;
|
||||
int index = RuntimeInformation.FrameworkDescription.LastIndexOf(' ');
|
||||
|
||||
// everything before the last space
|
||||
name = frameworkDescription.Substring(0, index).Trim();
|
||||
|
||||
// everything after the last space
|
||||
version = frameworkDescription.Substring(index).Trim();
|
||||
}
|
||||
|
||||
internal class ApiResponse
|
||||
{
|
||||
[JsonProperty("rate_by_service")]
|
||||
|
|
|
|||
|
|
@ -14,11 +14,17 @@ namespace Datadog.Trace
|
|||
public const string Language = "Datadog-Meta-Lang";
|
||||
|
||||
/// <summary>
|
||||
/// The interpreter version for the given language, e.g. ".NET Framework 4.7.2" or ".NET Core 2.1".
|
||||
/// The interpreter for the given language, e.g. ".NET Framework" or ".NET Core".
|
||||
/// The value of <see cref="RuntimeInformation.FrameworkDescription"/>.
|
||||
/// </summary>
|
||||
public const string LanguageInterpreter = "Datadog-Meta-Lang-Interpreter";
|
||||
|
||||
/// <summary>
|
||||
/// The interpreter version for the given language, e.g. "4.7.2" for .NET Framework or "2.1" for .NET Core.
|
||||
/// The value of <see cref="RuntimeInformation.FrameworkDescription"/>.
|
||||
/// </summary>
|
||||
public const string LanguageVersion = "Datadog-Meta-Lang-Version";
|
||||
|
||||
/// <summary>
|
||||
/// The version of the tracer that generated this span.
|
||||
/// </summary>
|
||||
|
|
|
|||
Loading…
Reference in New Issue