Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ResourceBuilder API #1533

Merged
merged 21 commits into from
Nov 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/Console/TestConsoleExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ internal static object Run(ConsoleOptions options)
// and use a custom MyProcessor, along with Console exporter.
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
.AddSource("MyCompany.MyProduct.MyWebServer")
.SetResource(Resources.CreateServiceResource("MyServiceName"))
.SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("MyServiceName"))
.AddProcessor(new MyProcessor()) // This must be added before ConsoleExporter
.AddConsoleExporter()
.Build();
Expand Down
2 changes: 1 addition & 1 deletion examples/Console/TestHttpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ internal static object Run()

using var openTelemetry = Sdk.CreateTracerProviderBuilder()
.AddHttpClientInstrumentation()
.SetResource(Resources.CreateServiceResource("http-service-example"))
.SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("http-service-example"))
.AddSource("http-client-test")
.AddConsoleExporter()
.Build();
Expand Down
2 changes: 1 addition & 1 deletion examples/Console/TestOTelShimWithConsoleExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ internal static object Run(OpenTelemetryShimOptions options)
// and use a single pipeline with a custom MyProcessor, and Console exporter.
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
.AddSource("MyCompany.MyProduct.MyWebServer")
.SetResource(Resources.CreateServiceResource("MyServiceName"))
.SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("MyServiceName"))
.AddConsoleExporter()
.Build();

Expand Down
2 changes: 1 addition & 1 deletion examples/Console/TestOpenTracingWithConsoleExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ internal static object Run(OpenTracingShimOptions options)
// and use Console exporter.
using var openTelemetry = Sdk.CreateTracerProviderBuilder()
.AddSource("MyCompany.MyProduct.MyWebServer")
.SetResource(Resources.CreateServiceResource("MyServiceName"))
.SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("MyServiceName"))
.AddConsoleExporter()
.Build();

Expand Down
44 changes: 0 additions & 44 deletions src/OpenTelemetry.Api/Internal/SemanticConventions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,50 +26,6 @@ internal static class SemanticConventions
// https://github.com/open-telemetry/opentelemetry-specification/tree/master/specification/trace/semantic_conventions
// https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/semantic_conventions/exceptions.md
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
public const string AttributeServiceName = "service.name";
public const string AttributeServiceNamespace = "service.namespace";
public const string AttributeServiceInstance = "service.instance.id";
public const string AttributeServiceVersion = "service.version";

public const string AttributeTelemetrySdkName = "telemetry.sdk.name";
public const string AttributeTelemetrySdkLanguage = "telemetry.sdk.language";
public const string AttributeTelemetrySdkVersion = "telemetry.sdk.version";

public const string AttributeContainerName = "container.name";
public const string AttributeContainerImage = "container.image.name";
public const string AttributeContainerTag = "container.image.tag";

public const string AttributeFaasName = "faas.name";
public const string AttributeFaasId = "faas.id";
public const string AttributeFaasVersion = "faas.version";
public const string AttributeFaasInstance = "faas.instance";

public const string AttributeK8sCluster = "k8s.cluster.name";
public const string AttributeK8sNamespace = "k8s.namespace.name";
public const string AttributeK8sPod = "k8s.pod.name";
public const string AttributeK8sDeployment = "k8s.deployment.name";

public const string AttributeHostHostname = "host.hostname";
public const string AttributeHostId = "host.id";
public const string AttributeHostName = "host.name";
public const string AttributeHostType = "host.type";
public const string AttributeHostImageName = "host.image.name";
public const string AttributeHostImageId = "host.image.id";
public const string AttributeHostImageVersion = "host.image.version";

public const string AttributeProcessId = "process.id";
public const string AttributeProcessExecutableName = "process.executable.name";
public const string AttributeProcessExecutablePath = "process.executable.path";
public const string AttributeProcessCommand = "process.command";
public const string AttributeProcessCommandLine = "process.command_line";
public const string AttributeProcessUsername = "process.username";

public const string AttributeCloudProvider = "cloud.provider";
public const string AttributeCloudAccount = "cloud.account.id";
public const string AttributeCloudRegion = "cloud.region";
public const string AttributeCloudZone = "cloud.zone";
public const string AttributeComponent = "component";

public const string AttributeNetTransport = "net.transport";
public const string AttributeNetPeerIp = "net.peer.ip";
public const string AttributeNetPeerPort = "net.peer.port";
Expand Down
4 changes: 2 additions & 2 deletions src/OpenTelemetry.Exporter.Jaeger/JaegerExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ internal void SetResource(Resource resource)
{
switch (key)
{
case Resource.ServiceNameKey:
case ResourceSemanticConventions.AttributeServiceName:
serviceName = strVal;
continue;
case Resource.ServiceNamespaceKey:
case ResourceSemanticConventions.AttributeServiceNamespace:
serviceNamespace = strVal;
continue;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net46;netstandard2.0;netstandard2.1</TargetFrameworks>
Expand All @@ -18,7 +18,8 @@
<Compile Include="$(RepoRoot)\src\OpenTelemetry.Api\Internal\IActivityEnumerator.cs" Link="Includes\IActivityEnumerator.cs" />
<Compile Include="$(RepoRoot)\src\OpenTelemetry.Api\Internal\EnumerationHelper.cs" Link="Includes\EnumerationHelper.cs" />
<Compile Include="$(RepoRoot)\src\OpenTelemetry\Internal\PooledList.cs" Link="Includes\PooledList.cs" />
<Compile Include="$(RepoRoot)\src\OpenTelemetry\Exporter\PeerServiceResolver.cs" Link="Includes\PeerServiceResolver.cs" />
<Compile Include="$(RepoRoot)\src\OpenTelemetry\Internal\PeerServiceResolver.cs" Link="Includes\PeerServiceResolver.cs" />
<Compile Include="$(RepoRoot)\src\OpenTelemetry\Internal\ResourceSemanticConventions.cs" Link="Includes\ResourceSemanticConventions.cs" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
<Compile Include="$(RepoRoot)\src\OpenTelemetry.Api\Internal\IActivityEnumerator.cs" Link="Includes\IActivityEnumerator.cs" />
<Compile Include="$(RepoRoot)\src\OpenTelemetry.Api\Internal\EnumerationHelper.cs" Link="Includes\EnumerationHelper.cs" />
<Compile Include="$(RepoRoot)\src\OpenTelemetry\Internal\PooledList.cs" Link="Includes\PooledList.cs" />
<Compile Include="$(RepoRoot)\src\OpenTelemetry\Exporter\PeerServiceResolver.cs" Link="Includes\PeerServiceResolver.cs" />
<Compile Include="$(RepoRoot)\src\OpenTelemetry\Internal\PeerServiceResolver.cs" Link="Includes\PeerServiceResolver.cs" />
<Compile Include="$(RepoRoot)\src\OpenTelemetry\Internal\ResourceSemanticConventions.cs" Link="Includes\ResourceSemanticConventions.cs" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ internal void SetResource(Resource resource)
}
}

if (!processResource.Attributes.Any(kvp => kvp.Key == Resource.ServiceNameKey))
if (!processResource.Attributes.Any(kvp => kvp.Key == ResourceSemanticConventions.AttributeServiceName))
{
string serviceName = this.options.ServiceName;
if (string.IsNullOrEmpty(serviceName))
Expand All @@ -114,7 +114,7 @@ internal void SetResource(Resource resource)

processResource.Attributes.Add(new OtlpCommon.KeyValue
{
Key = Resource.ServiceNameKey,
Key = ResourceSemanticConventions.AttributeServiceName,
Value = new OtlpCommon.AnyValue { StringValue = serviceName },
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
<Compile Include="$(RepoRoot)\src\OpenTelemetry.Api\Internal\IActivityEnumerator.cs" Link="Includes\IActivityEnumerator.cs" />
<Compile Include="$(RepoRoot)\src\OpenTelemetry.Api\Internal\EnumerationHelper.cs" Link="Includes\EnumerationHelper.cs" />
<Compile Include="$(RepoRoot)\src\OpenTelemetry\Internal\PooledList.cs" Link="Includes\PooledList.cs" />
<Compile Include="$(RepoRoot)\src\OpenTelemetry\Exporter\PeerServiceResolver.cs" Link="Includes\PeerServiceResolver.cs" />
<Compile Include="$(RepoRoot)\src\OpenTelemetry\Internal\PeerServiceResolver.cs" Link="Includes\PeerServiceResolver.cs" />
<Compile Include="$(RepoRoot)\src\OpenTelemetry\Internal\ResourceSemanticConventions.cs" Link="Includes\ResourceSemanticConventions.cs" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/OpenTelemetry.Exporter.Zipkin/ZipkinExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ internal void SetLocalEndpointFromResource(Resource resource)

switch (key)
{
case Resource.ServiceNameKey:
case ResourceSemanticConventions.AttributeServiceName:
serviceName = label.Value as string;
continue;
}
Expand Down
19 changes: 12 additions & 7 deletions src/OpenTelemetry/.publicApi/net452/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,11 @@ OpenTelemetry.Resources.Resource
OpenTelemetry.Resources.Resource.Attributes.get -> System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string, object>>
OpenTelemetry.Resources.Resource.Merge(OpenTelemetry.Resources.Resource other) -> OpenTelemetry.Resources.Resource
OpenTelemetry.Resources.Resource.Resource(System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string, object>> attributes) -> void
OpenTelemetry.Resources.Resources
OpenTelemetry.Resources.ResourceBuilder
OpenTelemetry.Resources.ResourceBuilder.AddResource(OpenTelemetry.Resources.Resource resource) -> OpenTelemetry.Resources.ResourceBuilder
OpenTelemetry.Resources.ResourceBuilder.Build() -> OpenTelemetry.Resources.Resource
OpenTelemetry.Resources.ResourceBuilder.Clear() -> OpenTelemetry.Resources.ResourceBuilder
OpenTelemetry.ResourceBuilderExtensions
OpenTelemetry.Sdk
OpenTelemetry.SimpleExportProcessor<T>
OpenTelemetry.SimpleExportProcessor<T>.SimpleExportProcessor(OpenTelemetry.BaseExporter<T> exporter) -> void
Expand Down Expand Up @@ -176,10 +180,6 @@ abstract OpenTelemetry.Metrics.Export.MetricExporter.ExportAsync(System.Collecti
abstract OpenTelemetry.Metrics.Export.MetricProcessor.FinishCollectionCycle(out System.Collections.Generic.IEnumerable<OpenTelemetry.Metrics.Export.Metric> metrics) -> void
abstract OpenTelemetry.Metrics.Export.MetricProcessor.Process(OpenTelemetry.Metrics.Export.Metric metric) -> void
abstract OpenTelemetry.Trace.Sampler.ShouldSample(in OpenTelemetry.Trace.SamplingParameters samplingParameters) -> OpenTelemetry.Trace.SamplingResult
const OpenTelemetry.Resources.Resource.ServiceInstanceIdKey = "service.instance.id" -> string
const OpenTelemetry.Resources.Resource.ServiceNameKey = "service.name" -> string
const OpenTelemetry.Resources.Resource.ServiceNamespaceKey = "service.namespace" -> string
const OpenTelemetry.Resources.Resource.ServiceVersionKey = "service.version" -> string
override OpenTelemetry.BaseExportProcessor<T>.Dispose(bool disposing) -> void
override OpenTelemetry.BaseExportProcessor<T>.OnShutdown(int timeoutMilliseconds) -> bool
override OpenTelemetry.BatchExportProcessor<T>.OnEnd(T data) -> void
Expand Down Expand Up @@ -227,8 +227,13 @@ override abstract OpenTelemetry.BaseExportProcessor<T>.OnEnd(T data) -> void
override sealed OpenTelemetry.BaseExportProcessor<T>.OnStart(T data) -> void
readonly OpenTelemetry.BaseExportProcessor<T>.exporter -> OpenTelemetry.BaseExporter<T>
static OpenTelemetry.ProviderExtensions.GetResource(this OpenTelemetry.BaseProvider baseProvider) -> OpenTelemetry.Resources.Resource
static OpenTelemetry.ResourceBuilderExtensions.AddEnvironmentVariableDetector(this OpenTelemetry.Resources.ResourceBuilder resourceBuilder) -> OpenTelemetry.Resources.ResourceBuilder
static OpenTelemetry.Resources.Resource.Empty.get -> OpenTelemetry.Resources.Resource
static OpenTelemetry.Resources.Resources.CreateServiceResource(string serviceName, string serviceInstanceId = null, string serviceNamespace = null, string serviceVersion = null) -> OpenTelemetry.Resources.Resource
static OpenTelemetry.ResourceBuilderExtensions.AddAttributes(this OpenTelemetry.Resources.ResourceBuilder resourceBuilder, System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string, object>> attributes) -> OpenTelemetry.Resources.ResourceBuilder
static OpenTelemetry.ResourceBuilderExtensions.AddService(this OpenTelemetry.Resources.ResourceBuilder resourceBuilder, string serviceName, string serviceNamespace = null, string serviceVersion = null, bool autoGenerateServiceInstanceId = true, string serviceInstanceId = null) -> OpenTelemetry.Resources.ResourceBuilder
static OpenTelemetry.ResourceBuilderExtensions.AddTelemetrySdk(this OpenTelemetry.Resources.ResourceBuilder resourceBuilder) -> OpenTelemetry.Resources.ResourceBuilder
static OpenTelemetry.Resources.ResourceBuilder.CreateDefault() -> OpenTelemetry.Resources.ResourceBuilder
static OpenTelemetry.Resources.ResourceBuilder.CreateEmpty() -> OpenTelemetry.Resources.ResourceBuilder
static OpenTelemetry.Sdk.CreateMeterProviderBuilder() -> OpenTelemetry.Metrics.MeterProviderBuilder
static OpenTelemetry.Sdk.CreateTracerProviderBuilder() -> OpenTelemetry.Trace.TracerProviderBuilder
static OpenTelemetry.Sdk.SetDefaultTextMapPropagator(OpenTelemetry.Context.Propagation.TextMapPropagator textMapPropagator) -> void
Expand All @@ -239,7 +244,7 @@ static OpenTelemetry.Trace.SamplingResult.operator !=(OpenTelemetry.Trace.Sampli
static OpenTelemetry.Trace.SamplingResult.operator ==(OpenTelemetry.Trace.SamplingResult decision1, OpenTelemetry.Trace.SamplingResult decision2) -> bool
static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddProcessor(this OpenTelemetry.Trace.TracerProviderBuilder tracerProviderBuilder, OpenTelemetry.BaseProcessor<System.Diagnostics.Activity> processor) -> OpenTelemetry.Trace.TracerProviderBuilder
static OpenTelemetry.Trace.TracerProviderBuilderExtensions.Build(this OpenTelemetry.Trace.TracerProviderBuilder tracerProviderBuilder) -> OpenTelemetry.Trace.TracerProvider
static OpenTelemetry.Trace.TracerProviderBuilderExtensions.SetResource(this OpenTelemetry.Trace.TracerProviderBuilder tracerProviderBuilder, OpenTelemetry.Resources.Resource resource) -> OpenTelemetry.Trace.TracerProviderBuilder
static OpenTelemetry.Trace.TracerProviderBuilderExtensions.SetResourceBuilder(this OpenTelemetry.Trace.TracerProviderBuilder tracerProviderBuilder, OpenTelemetry.Resources.ResourceBuilder resourceBuilder) -> OpenTelemetry.Trace.TracerProviderBuilder
static OpenTelemetry.Trace.TracerProviderBuilderExtensions.SetSampler(this OpenTelemetry.Trace.TracerProviderBuilder tracerProviderBuilder, OpenTelemetry.Trace.Sampler sampler) -> OpenTelemetry.Trace.TracerProviderBuilder
static OpenTelemetry.Trace.TracerProviderExtensions.AddProcessor(this OpenTelemetry.Trace.TracerProvider provider, OpenTelemetry.BaseProcessor<System.Diagnostics.Activity> processor) -> OpenTelemetry.Trace.TracerProvider
static OpenTelemetry.Trace.TracerProviderExtensions.Shutdown(this OpenTelemetry.Trace.TracerProvider provider, int timeoutMilliseconds = -1) -> bool
Expand Down
Loading