diff --git a/README.md b/README.md index b12a438..8d0fc9b 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ This sample is designed to work with [DataDog Application Performance Monitoring To run this sample, you will need a copy of your DataDog API Key - which will be passed into the local Kubernetes cluster created by this tutorial. -To [get your DataDog API Key for use with DataDog's Helm Agent, click here](https://app.datadoghq.com/account/settings#agent/kubernetes). +**To [get your DataDog API Key for use with DataDog's Helm Agent, click here](https://app.datadoghq.com/account/settings#agent/kubernetes)**. ### Retreiving the DataDog Helm Charts This sample uses [Helm](https://helm.sh/) to install [DataDog's Agent Helm Chart](https://github.com/DataDog/helm-charts/blob/master/charts/datadog/README.md) into a local Kubernetes cluster. diff --git a/k8s/datadog/datadog-values.yaml b/k8s/datadog/datadog-values.yaml index 5808d86..e8f2f55 100644 --- a/k8s/datadog/datadog-values.yaml +++ b/k8s/datadog/datadog-values.yaml @@ -156,11 +156,11 @@ datadog: logs: # datadog.logs.enabled -- Enables this to activate Datadog Agent log collection ## ref: https://docs.datadoghq.com/agent/basic_agent_usage/kubernetes/#log-collection-setup - enabled: false + enabled: true # datadog.logs.containerCollectAll -- Enable this to allow log collection for all containers ## ref: https://docs.datadoghq.com/agent/basic_agent_usage/kubernetes/#log-collection-setup - containerCollectAll: false + containerCollectAll: true # datadog.logs.containerCollectUsingFiles -- Collect logs from files in /var/log/pods instead of using container runtime API ## It's usually the most efficient way of collecting logs. diff --git a/k8s/environment/configs/configs.yaml b/k8s/environment/configs/configs.yaml index f19c6b1..82114f7 100644 --- a/k8s/environment/configs/configs.yaml +++ b/k8s/environment/configs/configs.yaml @@ -5,4 +5,8 @@ metadata: name: pb-configs data: # Configuration values can be set as key-value properties - environment: Development \ No newline at end of file + environment: "Development" + dd-service: "akka.cluster" + dd-dogstatsd-port: "8125" + dd-trace-agent-port: "8126" + dd-apm-receiver-port: "8126" \ No newline at end of file diff --git a/k8s/services/petabridge.phobos.web.datadog.yaml b/k8s/services/petabridge.phobos.web.datadog.yaml index ca3a56d..6e2d04c 100644 --- a/k8s/services/petabridge.phobos.web.datadog.yaml +++ b/k8s/services/petabridge.phobos.web.datadog.yaml @@ -72,10 +72,38 @@ spec: configMapKeyRef: name: pb-configs key: environment + - name: DD_ENV + valueFrom: + fieldRef: + fieldPath: metadata.labels['tags.datadoghq.com/env'] + - name: DD_SERVICE + valueFrom: + configMapKeyRef: + name: pb-configs + key: dd-service + - name: DD_VERSION + valueFrom: + fieldRef: + fieldPath: metadata.labels['tags.datadoghq.com/version'] - name: DD_AGENT_HOST valueFrom: fieldRef: fieldPath: status.hostIP + - name: DD_DOGSTATSD_PORT + valueFrom: + configMapKeyRef: + name: pb-configs + key: dd-dogstatsd-port + - name: DD_TRACE_AGENT_PORT + valueFrom: + configMapKeyRef: + name: pb-configs + key: dd-trace-agent-port + - name: DD_APM_RECEIVER_PORT + valueFrom: + configMapKeyRef: + name: pb-configs + key: dd-apm-receiver-port - name: DD_API_KEY valueFrom: secretKeyRef: diff --git a/src/Petabridge.Phobos.Web.DataDog/Dockerfile b/src/Petabridge.Phobos.Web.DataDog/Dockerfile index 09837dd..aeb12d0 100644 --- a/src/Petabridge.Phobos.Web.DataDog/Dockerfile +++ b/src/Petabridge.Phobos.Web.DataDog/Dockerfile @@ -30,4 +30,21 @@ COPY --from=base /root/.dotnet /root/.dotnet/ # Needed because https://stackoverflow.com/questions/51977474/install-dotnet-core-tool-dockerfile ENV PATH="${PATH}:/root/.dotnet/tools" +# Please select the corresponding download for your Linux containers https://github.com/DataDog/dd-trace-dotnet/releases/latest + +# Download and install the Tracer +RUN mkdir -p /opt/datadog \ + && mkdir -p /var/log/datadog \ + && TRACER_VERSION=$(curl -s https://api.github.com/repos/DataDog/dd-trace-dotnet/releases/latest | grep tag_name | cut -d '"' -f 4 | cut -c2-) \ + && curl -LO https://github.com/DataDog/dd-trace-dotnet/releases/download/v${TRACER_VERSION}/datadog-dotnet-apm_${TRACER_VERSION}_amd64.deb \ + && dpkg -i ./datadog-dotnet-apm_${TRACER_VERSION}_amd64.deb \ + && rm ./datadog-dotnet-apm_${TRACER_VERSION}_amd64.deb + +# Enable the tracer +ENV CORECLR_ENABLE_PROFILING=1 +ENV CORECLR_PROFILER={846F5F1C-F9AE-4B07-969E-05C26BC060D8} +ENV CORECLR_PROFILER_PATH=/opt/datadog/Datadog.Trace.ClrProfiler.Native.so +ENV DD_DOTNET_TRACER_HOME=/opt/datadog +ENV DD_INTEGRATIONS=/opt/datadog/integrations.json + CMD ["dotnet", "Petabridge.Phobos.Web.DataDog.dll"] \ No newline at end of file diff --git a/src/Petabridge.Phobos.Web.DataDog/Startup.cs b/src/Petabridge.Phobos.Web.DataDog/Startup.cs index 8f647c1..505bae4 100644 --- a/src/Petabridge.Phobos.Web.DataDog/Startup.cs +++ b/src/Petabridge.Phobos.Web.DataDog/Startup.cs @@ -86,7 +86,7 @@ public static void ConfigureAppMetrics(IServiceCollection services) .Report.ToStatsDUdp(opt => { opt.SocketSettings.Address = Environment.GetEnvironmentVariable("DD_AGENT_HOST"); - opt.SocketSettings.Port = 8125; + opt.SocketSettings.Port = int.Parse(Environment.GetEnvironmentVariable("DD_DOGSTATSD_PORT")); opt.SocketSettings.MaxUdpDatagramSize = 1024 * 4; opt.StatsDOptions.MetricNameFormatter = new DefaultDogStatsDMetricStringSerializer(); }) @@ -98,10 +98,8 @@ public static void ConfigureAppMetrics(IServiceCollection services) public static void ConfigureDataDogTracing(IServiceCollection services) { // Add DataDog Tracing - services.AddSingleton(sp => - { - return OpenTracingTracerFactory.CreateTracer().WithScopeManager(new ActorScopeManager()); - }); + var tracer = OpenTracingTracerFactory.CreateTracer().WithScopeManager(new ActorScopeManager()); + services.AddSingleton(tracer); } public static void ConfigureAkka(IServiceCollection services) @@ -119,8 +117,7 @@ public static void ConfigureAkka(IServiceCollection services) .WithTracing(t => t.SetTracer(tracer))) // binds Phobos to same tracer as ASP.NET Core .WithSetup(BootstrapSetup.Create() .WithConfig(config) // passes in the HOCON for Akka.NET to the ActorSystem - .WithActorRefProvider(PhobosProviderSelection - .Cluster)); // last line activates Phobos inside Akka.NET + .WithActorRefProvider(PhobosProviderSelection.Cluster)); // last line activates Phobos inside Akka.NET var sys = ActorSystem.Create("ClusterSys", phobosSetup); diff --git a/src/Petabridge.Phobos.Web.DataDog/app.conf b/src/Petabridge.Phobos.Web.DataDog/app.conf index 0a98a37..2404a22 100644 --- a/src/Petabridge.Phobos.Web.DataDog/app.conf +++ b/src/Petabridge.Phobos.Web.DataDog/app.conf @@ -15,6 +15,7 @@ petabridge.cmd{ } akka { + loggers = ["Akka.Event.DefaultLogger", "Phobos.Tracing.DataDogLogger, Phobos.Tracing"] actor { provider = cluster diff --git a/src/common.props b/src/common.props index 5c57824..7ebf967 100644 --- a/src/common.props +++ b/src/common.props @@ -2,7 +2,7 @@ Copyright © 2019-2021 Petabridge Petabridge - 0.1.0 + 0.1.1 First release @@ -24,4 +24,4 @@ 6.2.0 1.2.5 - + \ No newline at end of file