Remove stackdriver exporter (#665)
This commit is contained in:
parent
c731b7b38a
commit
e11de97b25
|
|
@ -39,8 +39,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".vsts", ".vsts", "{61188153
|
|||
.vsts\ci-myget-update.yml = .vsts\ci-myget-update.yml
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Exporter.Stackdriver", "src\OpenTelemetry.Exporter.Stackdriver\OpenTelemetry.Exporter.Stackdriver.csproj", "{DE1B4783-C01F-4672-A6EB-695F1717105B}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Api", "src\OpenTelemetry.Api\OpenTelemetry.Api.csproj", "{99F8A331-05E9-45A5-89BA-4C54E825E5B2}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Exporter.Prometheus", "src\OpenTelemetry.Exporter.Prometheus\OpenTelemetry.Exporter.Prometheus.csproj", "{AD9B2B54-EC9C-448E-BD3C-EDCC3F7AD022}"
|
||||
|
|
@ -57,8 +55,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "testdata", "testdata", "{77
|
|||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestApp.AspNetCore.3.1", "test\TestApp.AspNetCore.3.1\TestApp.AspNetCore.3.1.csproj", "{F2F81E76-6A0E-466B-B673-EBBF1A9ED075}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Exporter.Stackdriver.Tests", "test\OpenTelemetry.Exporter.Stackdriver.Tests\OpenTelemetry.Exporter.Stackdriver.Tests.csproj", "{6875032B-DFDC-4CDE-A283-37CA7F99926A}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Adapter.StackExchangeRedis", "src\OpenTelemetry.Adapter.StackExchangeRedis\OpenTelemetry.Adapter.StackExchangeRedis.csproj", "{6B681D72-D68A-44CC-8C75-53B9A322E6EC}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Adapter.StackExchangeRedis.Tests", "test\OpenTelemetry.Adapter.StackExchangeRedis.Tests\OpenTelemetry.Adapter.StackExchangeRedis.Tests.csproj", "{CA98AF29-0852-4ADD-A66B-7E96266EE7B7}"
|
||||
|
|
@ -136,10 +132,6 @@ Global
|
|||
{4493F5D9-874E-4FBF-B2F3-37890BD910E0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4493F5D9-874E-4FBF-B2F3-37890BD910E0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4493F5D9-874E-4FBF-B2F3-37890BD910E0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{DE1B4783-C01F-4672-A6EB-695F1717105B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{DE1B4783-C01F-4672-A6EB-695F1717105B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{DE1B4783-C01F-4672-A6EB-695F1717105B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{DE1B4783-C01F-4672-A6EB-695F1717105B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{99F8A331-05E9-45A5-89BA-4C54E825E5B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{99F8A331-05E9-45A5-89BA-4C54E825E5B2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{99F8A331-05E9-45A5-89BA-4C54E825E5B2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
|
|
@ -168,10 +160,6 @@ Global
|
|||
{F2F81E76-6A0E-466B-B673-EBBF1A9ED075}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F2F81E76-6A0E-466B-B673-EBBF1A9ED075}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F2F81E76-6A0E-466B-B673-EBBF1A9ED075}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{6875032B-DFDC-4CDE-A283-37CA7F99926A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{6875032B-DFDC-4CDE-A283-37CA7F99926A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6875032B-DFDC-4CDE-A283-37CA7F99926A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6875032B-DFDC-4CDE-A283-37CA7F99926A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{1FA1F509-7722-48E3-9A35-16CBB6774957}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1FA1F509-7722-48E3-9A35-16CBB6774957}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1FA1F509-7722-48E3-9A35-16CBB6774957}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@
|
|||
<ProjectReference Include="..\..\..\src\OpenTelemetry.Adapter.StackExchangeRedis\OpenTelemetry.Adapter.StackExchangeRedis.csproj" />
|
||||
<ProjectReference Include="..\..\..\src\OpenTelemetry.Exporter.Console\OpenTelemetry.Exporter.Console.csproj" />
|
||||
<ProjectReference Include="..\..\..\src\OpenTelemetry.Exporter.OpenTelemetryProtocol\OpenTelemetry.Exporter.OpenTelemetryProtocol.csproj" />
|
||||
<ProjectReference Include="..\..\..\src\OpenTelemetry.Exporter.Stackdriver\OpenTelemetry.Exporter.Stackdriver.csproj" />
|
||||
<ProjectReference Include="..\..\..\src\OpenTelemetry.Exporter.Prometheus\OpenTelemetry.Exporter.Prometheus.csproj" />
|
||||
<ProjectReference Include="..\..\..\src\OpenTelemetry.Exporter.ZPages\OpenTelemetry.Exporter.ZPages.csproj" />
|
||||
<ProjectReference Include="..\..\..\src\OpenTelemetry\OpenTelemetry.csproj" />
|
||||
|
|
|
|||
|
|
@ -37,14 +37,13 @@ namespace Samples
|
|||
/// <param name="args">Arguments from command line.</param>
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
Parser.Default.ParseArguments<JaegerOptions, ZipkinOptions, PrometheusOptions, HttpClientOptions, StackdriverOptions, ZPagesOptions, ConsoleOptions, OtlpOptions>(args)
|
||||
Parser.Default.ParseArguments<JaegerOptions, ZipkinOptions, PrometheusOptions, HttpClientOptions, ZPagesOptions, ConsoleOptions, OtlpOptions>(args)
|
||||
.MapResult(
|
||||
(JaegerOptions options) => TestJaeger.Run(options.Host, options.Port),
|
||||
(ZipkinOptions options) => TestZipkin.Run(options.Uri),
|
||||
(PrometheusOptions options) => TestPrometheus.RunAsync(options.Port, options.PushIntervalInSecs, options.DurationInMins),
|
||||
(HttpClientOptions options) => TestHttpClient.Run(),
|
||||
(RedisOptions options) => TestRedis.Run(options.Uri),
|
||||
(StackdriverOptions options) => TestStackdriver.Run(options.ProjectId),
|
||||
(ZPagesOptions options) => TestZPages.Run(),
|
||||
(ConsoleOptions options) => TestConsole.Run(options),
|
||||
(OtlpOptions options) => TestOtlp.Run(options.Endpoint),
|
||||
|
|
@ -56,13 +55,6 @@ namespace Samples
|
|||
|
||||
#pragma warning disable SA1402 // File may only contain a single type
|
||||
|
||||
[Verb("stackdriver", HelpText = "Specify the options required to test Stackdriver exporter", Hidden = false)]
|
||||
internal class StackdriverOptions
|
||||
{
|
||||
[Option('p', "projectId", HelpText = "Please specify the projectId of your GCP project", Required = true)]
|
||||
public string ProjectId { get; set; }
|
||||
}
|
||||
|
||||
[Verb("jaeger", HelpText = "Specify the options required to test Jaeger exporter")]
|
||||
internal class JaegerOptions
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,63 +0,0 @@
|
|||
// <copyright file="TestStackdriver.cs" company="OpenTelemetry Authors">
|
||||
// Copyright 2018, OpenTelemetry Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// </copyright>
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using OpenTelemetry.Context;
|
||||
using OpenTelemetry.Exporter.Stackdriver;
|
||||
using OpenTelemetry.Trace;
|
||||
using OpenTelemetry.Trace.Configuration;
|
||||
|
||||
namespace Samples
|
||||
{
|
||||
internal class TestStackdriver
|
||||
{
|
||||
private static readonly string FrontendKey = "my_org/keys/frontend";
|
||||
|
||||
internal static object Run(string projectId)
|
||||
{
|
||||
var spanExporter = new StackdriverTraceExporter(projectId);
|
||||
|
||||
using var tracerFactory = TracerFactory.Create(builder => builder.AddProcessorPipeline(c => c.SetExporter(spanExporter)));
|
||||
var tracer = tracerFactory.GetTracer("stackdriver-test");
|
||||
|
||||
DistributedContext.Carrier = AsyncLocalDistributedContextCarrier.Instance; // Enable asynclocal carrier for the context
|
||||
DistributedContext dc = DistributedContextBuilder.CreateContext(FrontendKey, "mobile-ios9.3.5");
|
||||
|
||||
using (DistributedContext.SetCurrent(dc))
|
||||
{
|
||||
using (tracer.StartActiveSpan("/getuser", out TelemetrySpan span))
|
||||
{
|
||||
span.AddEvent("Processing video.");
|
||||
span.PutHttpMethodAttribute("GET");
|
||||
span.PutHttpHostAttribute("localhost", 8080);
|
||||
span.PutHttpPathAttribute("/resource");
|
||||
span.PutHttpStatusCodeAttribute(200);
|
||||
span.PutHttpUserAgentAttribute("Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0");
|
||||
|
||||
Thread.Sleep(TimeSpan.FromMilliseconds(10));
|
||||
}
|
||||
}
|
||||
|
||||
Thread.Sleep(TimeSpan.FromMilliseconds(5100));
|
||||
|
||||
Console.WriteLine("Done... wait for events to arrive to backend!");
|
||||
Console.ReadLine();
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
// <copyright file="AssemblyInfo.cs" company="OpenTelemetry Authors">
|
||||
// Copyright 2018, OpenTelemetry Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// </copyright>
|
||||
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
[assembly: InternalsVisibleTo("OpenTelemetry.Exporter.Stackdriver.Tests" + AssemblyInfo.PublicKey)]
|
||||
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2" + AssemblyInfo.MoqPublicKey)]
|
||||
|
||||
#if SIGNED
|
||||
internal static class AssemblyInfo
|
||||
{
|
||||
public const string PublicKey = ", PublicKey=002400000480000094000000060200000024000052534131000400000100010051C1562A090FB0C9F391012A32198B5E5D9A60E9B80FA2D7B434C9E5CCB7259BD606E66F9660676AFC6692B8CDC6793D190904551D2103B7B22FA636DCBB8208839785BA402EA08FC00C8F1500CCEF28BBF599AA64FFB1E1D5DC1BF3420A3777BADFE697856E9D52070A50C3EA5821C80BEF17CA3ACFFA28F89DD413F096F898";
|
||||
public const string MoqPublicKey = ", PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7";
|
||||
}
|
||||
#else
|
||||
internal static class AssemblyInfo
|
||||
{
|
||||
public const string PublicKey = "";
|
||||
public const string MoqPublicKey = "";
|
||||
}
|
||||
#endif
|
||||
|
|
@ -1,53 +0,0 @@
|
|||
// <copyright file="Constants.cs" company="OpenTelemetry Authors">
|
||||
// Copyright 2018, OpenTelemetry Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// </copyright>
|
||||
using System;
|
||||
|
||||
namespace OpenTelemetry.Exporter.Stackdriver.Implementation
|
||||
{
|
||||
internal class Constants
|
||||
{
|
||||
public static readonly string PackagVersionUndefined = "undefined";
|
||||
|
||||
public static readonly string LabelDescription = "OpenTelemetry string";
|
||||
public static readonly string OpenTelemetryTask = "OpenTelemetry_task";
|
||||
public static readonly string OpenTelemetryTaskDescription = "OpenTelemetry task identifier";
|
||||
|
||||
public static readonly string GcpGkeContainer = "k8s_container";
|
||||
public static readonly string GcpGceInstance = "gce_instance";
|
||||
public static readonly string AwsEc2Instance = "aws_ec2_instance";
|
||||
public static readonly string Global = "global";
|
||||
|
||||
public static readonly string ProjectIdLabelKey = "project_id";
|
||||
public static readonly string OpenTelemetryTaskValueDefault = GenerateDefaultTaskValue();
|
||||
|
||||
public static readonly string GceGcpInstanceType = "cloud.google.com/gce/instance";
|
||||
public static readonly string GcpInstanceIdKey = "cloud.google.com/gce/instance_id";
|
||||
public static readonly string GcpAccountIdKey = "cloud.google.com/gce/project_id";
|
||||
public static readonly string GcpZoneKey = "cloud.google.com/gce/zone";
|
||||
|
||||
public static readonly string K8sContainerType = "k8s.io/container";
|
||||
public static readonly string K8sClusterNameKey = "k8s.io/cluster/name";
|
||||
public static readonly string K8sContainerNameKey = "k8s.io/container/name";
|
||||
public static readonly string K8sNamespaceNameKey = "k8s.io/namespace/name";
|
||||
public static readonly string K8sPodNameKey = "k8s.io/pod/name";
|
||||
|
||||
private static string GenerateDefaultTaskValue()
|
||||
{
|
||||
// Something like '<pid>@<hostname>'
|
||||
return $"dotnet-{System.Diagnostics.Process.GetCurrentProcess().Id}@{Environment.MachineName}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,77 +0,0 @@
|
|||
// <copyright file="ExporterStackdriverEventSource.cs" company="OpenTelemetry Authors">
|
||||
// Copyright 2018, OpenTelemetry Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// </copyright>
|
||||
using System;
|
||||
using System.Diagnostics.Tracing;
|
||||
using System.Globalization;
|
||||
using System.Threading;
|
||||
|
||||
namespace OpenTelemetry.Exporter.Stackdriver.Implementation
|
||||
{
|
||||
[EventSource(Name = "OpenTelemetry-Exporter-Stackdriver")]
|
||||
internal class ExporterStackdriverEventSource : EventSource
|
||||
{
|
||||
public static readonly ExporterStackdriverEventSource Log = new ExporterStackdriverEventSource();
|
||||
|
||||
[NonEvent]
|
||||
public void UnknownProblemInWorkerThreadError(Exception ex)
|
||||
{
|
||||
if (Log.IsEnabled(EventLevel.Error, EventKeywords.All))
|
||||
{
|
||||
this.UnknownProblemInWorkerThreadError(ToInvariantString(ex));
|
||||
}
|
||||
}
|
||||
|
||||
[Event(1, Message = "Stackdriver exporter encountered an unknown error and will shut down. Exception: {0}", Level = EventLevel.Error)]
|
||||
public void UnknownProblemInWorkerThreadError(string ex)
|
||||
{
|
||||
this.WriteEvent(1, ex);
|
||||
}
|
||||
|
||||
[NonEvent]
|
||||
public void UnknownProblemWhileCreatingStackdriverTimeSeriesError(Exception ex)
|
||||
{
|
||||
if (Log.IsEnabled(EventLevel.Error, EventKeywords.All))
|
||||
{
|
||||
this.UnknownProblemWhileCreatingStackdriverTimeSeriesError(ToInvariantString(ex));
|
||||
}
|
||||
}
|
||||
|
||||
[Event(2, Message = "Stackdriver exporter failed to create time series. Time series will be lost. Exception: {0}", Level = EventLevel.Error)]
|
||||
public void UnknownProblemWhileCreatingStackdriverTimeSeriesError(string ex)
|
||||
{
|
||||
this.WriteEvent(2, ex);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a culture-independent string representation of the given <paramref name="exception"/> object,
|
||||
/// appropriate for diagnostics tracing.
|
||||
/// </summary>
|
||||
private static string ToInvariantString(Exception exception)
|
||||
{
|
||||
var originalUICulture = Thread.CurrentThread.CurrentUICulture;
|
||||
|
||||
try
|
||||
{
|
||||
Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture;
|
||||
return exception.ToString();
|
||||
}
|
||||
finally
|
||||
{
|
||||
Thread.CurrentThread.CurrentUICulture = originalUICulture;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,74 +0,0 @@
|
|||
// <copyright file="GoogleCloudResourceUtils.cs" company="OpenTelemetry Authors">
|
||||
// Copyright 2018, OpenTelemetry Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// </copyright>
|
||||
using System;
|
||||
using System.IO;
|
||||
using Google.Api;
|
||||
|
||||
namespace OpenTelemetry.Exporter.Stackdriver.Implementation
|
||||
{
|
||||
/// <summary>
|
||||
/// Utility methods for working with Google Cloud Resources.
|
||||
/// </summary>
|
||||
public static class GoogleCloudResourceUtils
|
||||
{
|
||||
/// <summary>
|
||||
/// Detects Google Cloud ProjectId based on the environment on which the code runs.
|
||||
/// Supports GCE/GKE/GAE and projectId tied to service account
|
||||
/// In case the code runs in a different environment,
|
||||
/// the method returns null.
|
||||
/// </summary>
|
||||
/// <returns>Google Cloud Project ID.</returns>
|
||||
public static string GetProjectId()
|
||||
{
|
||||
// Try to detect projectId from the environment where the code is running
|
||||
var instance = Google.Api.Gax.Platform.Instance();
|
||||
var projectId = instance?.ProjectId;
|
||||
if (!string.IsNullOrEmpty(projectId))
|
||||
{
|
||||
return projectId;
|
||||
}
|
||||
|
||||
// Try to detect projectId from service account credential if it exists
|
||||
var serviceAccountFilePath = Environment.GetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS");
|
||||
if (!string.IsNullOrEmpty(serviceAccountFilePath) && File.Exists(serviceAccountFilePath))
|
||||
{
|
||||
using var stream = new FileStream(serviceAccountFilePath, FileMode.Open, FileAccess.Read);
|
||||
var credential = Google.Apis.Auth.OAuth2.ServiceAccountCredential.FromServiceAccountData(stream);
|
||||
return credential.ProjectId;
|
||||
}
|
||||
|
||||
projectId = Environment.GetEnvironmentVariable("GOOGLE_PROJECT_ID");
|
||||
return projectId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determining the resource to which the metrics belong.
|
||||
/// </summary>
|
||||
/// <param name="projectId">The project id.</param>
|
||||
/// <returns>Stackdriver Monitored Resource.</returns>
|
||||
public static MonitoredResource GetDefaultResource(string projectId)
|
||||
{
|
||||
var resource = new MonitoredResource();
|
||||
resource.Type = Constants.Global;
|
||||
resource.Labels.Add(Constants.ProjectIdLabelKey, projectId);
|
||||
|
||||
// TODO - zeltser - setting monitored resource labels for detected resource
|
||||
// along with all the other metadata
|
||||
|
||||
return resource;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,155 +0,0 @@
|
|||
// <copyright file="SpanExtensions.cs" company="OpenTelemetry Authors">
|
||||
// Copyright 2018, OpenTelemetry Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// </copyright>
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Google.Cloud.Trace.V2;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using OpenTelemetry.Trace;
|
||||
using OpenTelemetry.Trace.Export;
|
||||
|
||||
namespace OpenTelemetry.Exporter.Stackdriver.Implementation
|
||||
{
|
||||
internal static class SpanExtensions
|
||||
{
|
||||
private static Dictionary<string, string> labelsToReplace = new Dictionary<string, string>
|
||||
{
|
||||
{ "component", "/component" },
|
||||
{ "http.method", "/http/method" },
|
||||
{ "http.host", "/http/host" },
|
||||
{ "http.status_code", "/http/status_code" },
|
||||
{ "http.user_agent", "/http/user_agent" },
|
||||
{ "http.path", "/http/path" },
|
||||
{ "http.url", "/http/url" },
|
||||
{ "http.route", "/http/route" },
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Translating <see cref="SpanData"/> to Stackdriver's Span
|
||||
/// According to <see href="https://cloud.google.com/trace/docs/reference/v2/rpc/google.devtools.cloudtrace.v2"/> specifications.
|
||||
/// </summary>
|
||||
/// <param name="spanData">Span in OpenTelemetry format.</param>
|
||||
/// <param name="projectId">Google Cloud Platform Project Id.</param>
|
||||
/// <returns><see cref="TelemetrySpan"/>.</returns>
|
||||
public static Google.Cloud.Trace.V2.Span ToSpan(this SpanData spanData, string projectId)
|
||||
{
|
||||
var spanId = spanData.Context.SpanId.ToHexString();
|
||||
|
||||
// Base span settings
|
||||
var span = new Google.Cloud.Trace.V2.Span
|
||||
{
|
||||
SpanName = new SpanName(projectId, spanData.Context.TraceId.ToHexString(), spanId),
|
||||
SpanId = spanId,
|
||||
DisplayName = new TruncatableString { Value = spanData.Name },
|
||||
StartTime = spanData.StartTimestamp.ToTimestamp(),
|
||||
EndTime = spanData.EndTimestamp.ToTimestamp(),
|
||||
ChildSpanCount = null,
|
||||
};
|
||||
if (spanData.ParentSpanId != null)
|
||||
{
|
||||
var parentSpanId = spanData.ParentSpanId.ToHexString();
|
||||
if (!string.IsNullOrEmpty(parentSpanId))
|
||||
{
|
||||
span.ParentSpanId = parentSpanId;
|
||||
}
|
||||
}
|
||||
|
||||
// Span Links
|
||||
if (spanData.Links != null)
|
||||
{
|
||||
span.Links = new Google.Cloud.Trace.V2.Span.Types.Links
|
||||
{
|
||||
Link = { spanData.Links.Select(l => l.ToLink()) },
|
||||
};
|
||||
}
|
||||
|
||||
// Span Attributes
|
||||
if (spanData.Attributes != null)
|
||||
{
|
||||
span.Attributes = new Google.Cloud.Trace.V2.Span.Types.Attributes
|
||||
{
|
||||
AttributeMap =
|
||||
{
|
||||
spanData.Attributes?.ToDictionary(
|
||||
s => s.Key,
|
||||
s => s.Value?.ToAttributeValue()),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
// StackDriver uses different labels that are used to categorize spans
|
||||
// replace attribute keys with StackDriver version
|
||||
foreach (var entry in labelsToReplace)
|
||||
{
|
||||
if (span.Attributes.AttributeMap.TryGetValue(entry.Key, out var attrValue))
|
||||
{
|
||||
span.Attributes.AttributeMap.Remove(entry.Key);
|
||||
span.Attributes.AttributeMap.Add(entry.Value, attrValue);
|
||||
}
|
||||
}
|
||||
|
||||
return span;
|
||||
}
|
||||
|
||||
public static Google.Cloud.Trace.V2.Span.Types.Link ToLink(this Link link)
|
||||
{
|
||||
var ret = new Google.Cloud.Trace.V2.Span.Types.Link();
|
||||
ret.SpanId = link.Context.SpanId.ToHexString();
|
||||
ret.TraceId = link.Context.TraceId.ToHexString();
|
||||
|
||||
if (link.Attributes != null)
|
||||
{
|
||||
ret.Attributes = new Google.Cloud.Trace.V2.Span.Types.Attributes
|
||||
{
|
||||
AttributeMap =
|
||||
{
|
||||
link.Attributes.ToDictionary(
|
||||
att => att.Key,
|
||||
att => att.Value.ToAttributeValue()),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static Google.Cloud.Trace.V2.AttributeValue ToAttributeValue(this object av)
|
||||
{
|
||||
switch (av)
|
||||
{
|
||||
case string s:
|
||||
return new Google.Cloud.Trace.V2.AttributeValue()
|
||||
{
|
||||
StringValue = new TruncatableString() { Value = s },
|
||||
};
|
||||
case bool b:
|
||||
return new Google.Cloud.Trace.V2.AttributeValue() { BoolValue = b };
|
||||
case long l:
|
||||
return new Google.Cloud.Trace.V2.AttributeValue() { IntValue = l };
|
||||
case double d:
|
||||
return new Google.Cloud.Trace.V2.AttributeValue()
|
||||
{
|
||||
StringValue = new TruncatableString() { Value = d.ToString() },
|
||||
};
|
||||
default:
|
||||
return new Google.Cloud.Trace.V2.AttributeValue()
|
||||
{
|
||||
StringValue = new TruncatableString() { Value = av.ToString() },
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,76 +0,0 @@
|
|||
// <copyright file="StackdriverStatsConfiguration.cs" company="OpenTelemetry Authors">
|
||||
// Copyright 2018, OpenTelemetry Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// </copyright>
|
||||
using System;
|
||||
using Google.Api;
|
||||
using Google.Apis.Auth.OAuth2;
|
||||
|
||||
namespace OpenTelemetry.Exporter.Stackdriver.Implementation
|
||||
{
|
||||
/// <summary>
|
||||
/// Configuration for exporting stats into Stackdriver.
|
||||
/// </summary>
|
||||
public class StackdriverStatsConfiguration
|
||||
{
|
||||
private static readonly TimeSpan DefaultInterval = TimeSpan.FromMinutes(1);
|
||||
|
||||
/// <summary>
|
||||
/// Gets default Stats Configuration for Stackdriver.
|
||||
/// </summary>
|
||||
public static StackdriverStatsConfiguration Default
|
||||
{
|
||||
get
|
||||
{
|
||||
var defaultConfig = new StackdriverStatsConfiguration
|
||||
{
|
||||
ExportInterval = DefaultInterval,
|
||||
ProjectId = GoogleCloudResourceUtils.GetProjectId(),
|
||||
MetricNamePrefix = string.Empty,
|
||||
};
|
||||
|
||||
defaultConfig.MonitoredResource = GoogleCloudResourceUtils.GetDefaultResource(defaultConfig.ProjectId);
|
||||
return defaultConfig;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets frequency of the export operation.
|
||||
/// </summary>
|
||||
public TimeSpan ExportInterval { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the prefix to append to every OpenTelemetry metric name in Stackdriver.
|
||||
/// </summary>
|
||||
public string MetricNamePrefix { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets google Cloud Project Id.
|
||||
/// </summary>
|
||||
public string ProjectId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets credential used to authenticate against Google Stackdriver Monitoring APIs.
|
||||
/// </summary>
|
||||
public GoogleCredential GoogleCredential { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets monitored Resource associated with metrics collection.
|
||||
/// By default, the exporter detects the environment where the export is happening,
|
||||
/// such as GKE/AWS/GCE. If the exporter is running on a different environment,
|
||||
/// monitored resource will be identified as "general".
|
||||
/// </summary>
|
||||
public MonitoredResource MonitoredResource { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net46;netstandard2.0</TargetFrameworks>
|
||||
<Description>Stackdriver .NET Exporter for OpenTelemetry.</Description>
|
||||
<PackageTags>$(PackageTags);Stackdriver;Google;GCP;distributed-tracing</PackageTags>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Google.Cloud.Monitoring.V3" Version="1.1.0-beta02" />
|
||||
<PackageReference Include="Google.Cloud.Trace.V2" Version="1.0.0-beta02" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\OpenTelemetry\OpenTelemetry.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
# Stackdriver Exporter for OpenTelemetry .NET
|
||||
|
||||
This sample assumes your code authenticates to Stackdriver APIs using [service account][gcp-auth] with
|
||||
credentials stored in environment variable GOOGLE_APPLICATION_CREDENTIALS.
|
||||
When you run on [GAE][GAE], [GKE][GKE] or locally with gcloud sdk installed - this is typically the case.
|
||||
There is also a constructor for specifying path to the service account credential. See [sample][stackdriver-sample] for details.
|
||||
|
||||
1. Add [Stackdriver Exporter package][OpenTelemetry-exporter-stackdriver-myget-url] reference.
|
||||
2. Enable [Stackdriver Trace][stackdriver-trace-setup] API.
|
||||
3. Enable [Stackdriver Monitoring][stackdriver-monitoring-setup] API.
|
||||
4. Instantiate a new instance of `StackdriverExporter` with your Google Cloud's ProjectId
|
||||
5. See [sample][stackdriver-sample] for example use.
|
||||
|
||||
#### Traces
|
||||
|
||||
```csharp
|
||||
var spanExporter = new StackdriverTraceExporter(projectId);
|
||||
|
||||
using var tracerFactory = TracerFactory.Create(builder => builder.AddProcessorPipeline(c => c.SetExporter(spanExporter)));
|
||||
var tracer = tracerFactory.GetTracer("stackdriver-test");
|
||||
|
||||
using (tracer.StartActiveSpan("/getuser", out TelemetrySpan span))
|
||||
{
|
||||
span.AddEvent("Processing video.");
|
||||
span.PutHttpMethodAttribute("GET");
|
||||
span.PutHttpHostAttribute("localhost", 8080);
|
||||
span.PutHttpPathAttribute("/resource");
|
||||
span.PutHttpStatusCodeAttribute(200);
|
||||
span.PutHttpUserAgentAttribute("Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0");
|
||||
|
||||
Thread.Sleep(TimeSpan.FromMilliseconds(10));
|
||||
}
|
||||
```
|
||||
|
||||
#### Metrics
|
||||
|
||||
```csharp
|
||||
var metricExporter = new StackdriverExporter(
|
||||
"YOUR-GOOGLE-PROJECT-ID",
|
||||
Stats.ViewManager);
|
||||
metricExporter.Start();
|
||||
```
|
||||
|
||||
[OpenTelemetry-exporter-stackdriver-nuget-image]:https://img.shields.io/nuget/vpre/OpenTelemetry.Exporter.Stackdriver.svg
|
||||
[OpenTelemetry-exporter-stackdriver-nuget-url]: https://www.nuget.org/packages/OpenTelemetry.Exporter.Stackdriver
|
||||
[stackdriver-trace-setup]: https://cloud.google.com/trace/docs/setup/
|
||||
[stackdriver-monitoring-setup]: https://cloud.google.com/monitoring/api/enable-api
|
||||
[GAE]: https://cloud.google.com/appengine/docs/flexible/dotnet/quickstart
|
||||
[GKE]: https://codelabs.developers.google.com/codelabs/cloud-kubernetes-aspnetcore/index.html?index=..%2F..index#0
|
||||
[gcp-auth]: https://cloud.google.com/docs/authentication/getting-started
|
||||
|
|
@ -1,113 +0,0 @@
|
|||
// <copyright file="StackdriverTraceExporter.cs" company="OpenTelemetry Authors">
|
||||
// Copyright 2018, OpenTelemetry Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// </copyright>
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Google.Api.Gax.Grpc;
|
||||
using Google.Cloud.Trace.V2;
|
||||
using Grpc.Core;
|
||||
using OpenTelemetry.Exporter.Stackdriver.Implementation;
|
||||
using OpenTelemetry.Trace.Export;
|
||||
|
||||
namespace OpenTelemetry.Exporter.Stackdriver
|
||||
{
|
||||
/// <summary>
|
||||
/// Exports a group of spans to Stackdriver.
|
||||
/// </summary>
|
||||
public class StackdriverTraceExporter : SpanExporter
|
||||
{
|
||||
private static readonly string StackdriverExportVersion;
|
||||
private static readonly string OpenTelemetryExporterVersion;
|
||||
|
||||
private readonly Google.Api.Gax.ResourceNames.ProjectName googleCloudProjectId;
|
||||
private readonly TraceServiceSettings traceServiceSettings;
|
||||
|
||||
static StackdriverTraceExporter()
|
||||
{
|
||||
try
|
||||
{
|
||||
var assemblyPackageVersion = typeof(StackdriverTraceExporter).GetTypeInfo().Assembly.GetCustomAttributes<AssemblyInformationalVersionAttribute>().First().InformationalVersion;
|
||||
StackdriverExportVersion = assemblyPackageVersion;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
StackdriverExportVersion = $"{Constants.PackagVersionUndefined}";
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
OpenTelemetryExporterVersion = Assembly.GetCallingAssembly().GetName().Version.ToString();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
OpenTelemetryExporterVersion = $"{Constants.PackagVersionUndefined}";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="StackdriverTraceExporter"/> class.
|
||||
/// </summary>
|
||||
/// <param name="projectId">Project ID to send telemetry to.</param>
|
||||
public StackdriverTraceExporter(string projectId)
|
||||
{
|
||||
this.googleCloudProjectId = new Google.Api.Gax.ResourceNames.ProjectName(projectId);
|
||||
|
||||
// Set header mutation for every outgoing API call to Stackdriver so the BE knows
|
||||
// which version of OC client is calling it as well as which version of the exporter
|
||||
var callSettings = CallSettings.FromHeaderMutation(StackdriverCallHeaderAppender);
|
||||
this.traceServiceSettings = new TraceServiceSettings();
|
||||
this.traceServiceSettings.CallSettings = callSettings;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override async Task<ExportResult> ExportAsync(IEnumerable<SpanData> spanDataList, CancellationToken cancellationToken)
|
||||
{
|
||||
var traceWriter = TraceServiceClient.Create(settings: this.traceServiceSettings);
|
||||
|
||||
var batchSpansRequest = new BatchWriteSpansRequest
|
||||
{
|
||||
ProjectName = this.googleCloudProjectId,
|
||||
Spans = { spanDataList.Select(s => s.ToSpan(this.googleCloudProjectId.ProjectId)) },
|
||||
};
|
||||
|
||||
// avoid cancelling here: this is no return point: if we reached this point
|
||||
// and cancellation is requested, it's better if we try to finish sending spans rather than drop it
|
||||
await traceWriter.BatchWriteSpansAsync(batchSpansRequest).ConfigureAwait(false);
|
||||
|
||||
// TODO failures
|
||||
return ExportResult.Success;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override Task ShutdownAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Appends OpenTelemetry headers for every outgoing request to Stackdriver Backend.
|
||||
/// </summary>
|
||||
/// <param name="metadata">The metadata that is sent with every outgoing http request.</param>
|
||||
private static void StackdriverCallHeaderAppender(Metadata metadata)
|
||||
{
|
||||
metadata.Add("AGENT_LABEL_KEY", "g.co/agent");
|
||||
metadata.Add("AGENT_LABEL_VALUE_STRING", $"{OpenTelemetryExporterVersion}; stackdriver-exporter {StackdriverExportVersion}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
// <copyright file="CommonUtils.cs" company="OpenTelemetry Authors">
|
||||
// Copyright 2018, OpenTelemetry Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// </copyright>
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace OpenTelemetry.Exporter.Stackdriver.Utils
|
||||
{
|
||||
/// <summary>
|
||||
/// Common Utility Methods that are not metrics/trace specific.
|
||||
/// </summary>
|
||||
public static class CommonUtils
|
||||
{
|
||||
/// <summary>
|
||||
/// Divide the source list into batches of lists of given size.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the list.</typeparam>
|
||||
/// <param name="source">The list.</param>
|
||||
/// <param name="size">Size of the batch.</param>
|
||||
/// <returns><see cref="IEnumerable{T}"/>.</returns>
|
||||
public static IEnumerable<IEnumerable<T>> Partition<T>(this IEnumerable<T> source, int size)
|
||||
{
|
||||
using var enumerator = source.GetEnumerator();
|
||||
while (enumerator.MoveNext())
|
||||
{
|
||||
yield return WalkPartition(enumerator, size - 1);
|
||||
}
|
||||
}
|
||||
|
||||
private static IEnumerable<T> WalkPartition<T>(IEnumerator<T> source, int size)
|
||||
{
|
||||
yield return source.Current;
|
||||
for (var i = 0; i < size && source.MoveNext(); i++)
|
||||
{
|
||||
yield return source.Current;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,67 +0,0 @@
|
|||
// <copyright file="StackdriverStatsConfigurationTests.cs" company="OpenTelemetry Authors">
|
||||
// Copyright 2018, OpenTelemetry Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// </copyright>
|
||||
using OpenTelemetry.Exporter.Stackdriver.Implementation;
|
||||
using System;
|
||||
using Xunit;
|
||||
|
||||
namespace OpenTelemetry.Exporter.Stackriver.Tests
|
||||
{
|
||||
public class StackdriverStatsConfigurationTests
|
||||
{
|
||||
public StackdriverStatsConfigurationTests()
|
||||
{
|
||||
// Setting this for unit testing purposes, so we don't need credentials for real Google Cloud Account
|
||||
Environment.SetEnvironmentVariable("GOOGLE_PROJECT_ID", "test", EnvironmentVariableTarget.Process);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void StatsConfiguration_ByDefault_MetricNamePrefixEmpty()
|
||||
{
|
||||
Assert.NotNull(StackdriverStatsConfiguration.Default);
|
||||
Assert.Equal(GoogleCloudResourceUtils.GetProjectId(), StackdriverStatsConfiguration.Default.ProjectId);
|
||||
Assert.Equal(string.Empty, StackdriverStatsConfiguration.Default.MetricNamePrefix);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void StatsConfiguration_ByDeafult_ProjectIdIsGoogleCloudProjectId()
|
||||
{
|
||||
Assert.NotNull(StackdriverStatsConfiguration.Default);
|
||||
Assert.Equal(GoogleCloudResourceUtils.GetProjectId(), StackdriverStatsConfiguration.Default.ProjectId);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void StatsConfiguration_ByDefault_ExportIntervalMinute()
|
||||
{
|
||||
Assert.Equal(TimeSpan.FromMinutes(1), StackdriverStatsConfiguration.Default.ExportInterval);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void StatsConfiguration_ByDefault_MonitoredResourceIsGlobal()
|
||||
{
|
||||
Assert.NotNull(StackdriverStatsConfiguration.Default.MonitoredResource);
|
||||
|
||||
Assert.Equal(Constants.Global, StackdriverStatsConfiguration.Default.MonitoredResource.Type);
|
||||
|
||||
Assert.NotNull(StackdriverStatsConfiguration.Default.MonitoredResource.Labels);
|
||||
|
||||
Assert.True(StackdriverStatsConfiguration.Default.MonitoredResource.Labels.ContainsKey("project_id"));
|
||||
Assert.True(StackdriverStatsConfiguration.Default.MonitoredResource.Labels.ContainsKey(Constants.ProjectIdLabelKey));
|
||||
Assert.Equal(
|
||||
StackdriverStatsConfiguration.Default.ProjectId,
|
||||
StackdriverStatsConfiguration.Default.MonitoredResource.Labels[Constants.ProjectIdLabelKey]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<Description>Unit test project for Stackdriver Exporter for OpenTelemetry</Description>
|
||||
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>
|
||||
<TargetFrameworks Condition="$(OS) == 'Windows_NT'">$(TargetFrameworks);net46</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="xunit.runner.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\OpenTelemetry.Exporter.Stackdriver\OpenTelemetry.Exporter.Stackdriver.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
|
||||
<PackageReference Include="Moq" Version="4.11.0" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||
</PackageReference>
|
||||
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
{
|
||||
"maxParallelThreads": 1,
|
||||
"parallelizeTestCollections": false
|
||||
}
|
||||
Loading…
Reference in New Issue