# Is the possible to merge service created by OpenTelemetry and OneAgent as one?

**URL:** <https://community.dynatrace.com/t/is-the-possible-to-merge-service-created-by-opentelemetry-and-oneagent-as-one/47527>\
**Category:** OpenTelemetry\
**Tags:** services-classic, opentelemetry, oneagent\
**Created:** [September 6, 2024, 12:25pm UTC](https://community.dynatrace.com/t/is-the-possible-to-merge-service-created-by-opentelemetry-and-oneagent-as-one/47527 "2024-09-06T12:25:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![xuzhao2024](https://avatars.discourse-cdn.com/v4/letter/x/c57346/32.png) [@xuzhao2024](https://community.dynatrace.com/u/xuzhao2024)\
**Post date:** [September 6, 2024, 12:25pm UTC](https://community.dynatrace.com/t/is-the-possible-to-merge-service-created-by-opentelemetry-and-oneagent-as-one/47527/1 "2024-09-06T12:25:18Z")

</div>

Hi guys,

We have set up a OneAgent process running in a Kubernetes (K8S) pod, which automatically collects trace and log data for the containerized application.

At the same time, we have implemented OpenTelemetry within the application to send trace and log data to the Dynatrace SaaS endpoint.

As a result, two services have been created on the Dynatrace platform: one through custom service detection and the other through OpenTelemetry.

 ![Untitled.png](https://global.discourse-cdn.com/dynatrace/original/2X/d/d139037daf3184156618de5d3313349b845dcd1f.png)

Would it make sense to combine these two services into one for easier monitoring and maintenance? If so, how should we approach this?

---

<div class="post-metadata">

**Author:** ![Eric\_Yu](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/eric_yu/32/20360_2.png) [@Eric\_Yu](https://community.dynatrace.com/u/Eric_Yu)\
**Post date:** [September 6, 2024, 1:18pm UTC](https://community.dynatrace.com/t/is-the-possible-to-merge-service-created-by-opentelemetry-and-oneagent-as-one/47527/2 "2024-09-06T13:18:02Z")

</div>

Are you ingesting the traces through the API? In this case, since you already have the agent, you might want to try and send those trace through the OneAgent.

[OpenTelemetry traces with OneAgent - Dynatrace Docs](https://docs.dynatrace.com/docs/extend-dynatrace/opentelemetry/getting-started/traces/oneagent)

This should merge any span you created into a single trace:

 ![Eric_Yu_0-1725628669669.png](https://global.discourse-cdn.com/dynatrace/original/3X/5/c/5cda19624c7d37d6eb719e22a7e68165c680d38a.png)

---

<div class="post-metadata">

**Author:** ![xuzhao2024](https://avatars.discourse-cdn.com/v4/letter/x/c57346/32.png) [@xuzhao2024](https://community.dynatrace.com/u/xuzhao2024)\
**Post date:** [September 13, 2024, 3:51am UTC](https://community.dynatrace.com/t/is-the-possible-to-merge-service-created-by-opentelemetry-and-oneagent-as-one/47527/3 "2024-09-13T03:51:29Z")

</div>

Hi,

I tried to follow the steps as mentioned in this page&nbsp;[Dynatrace OTLP API endpoints — Dynatrace Docs](https://docs.dynatrace.com/docs/shortlink/otel-getstarted-otlpexport#export-to-oneagent-traces-only). But it did not work on the K8S port.

 ![xuzhao2024_0-1726199229540.png](https://global.discourse-cdn.com/dynatrace/original/2X/5/5642f225d01aa386bf706be923aa178eb1a0ba59.png)

I got the open telemetry logs as below

```markup
2024-09-13T03:48:40.0018813Z:Activity started. Name = '{0}', Id = '{1}'.{PublishMessage}{00-0a5b9b74e081d09479bf7322d5b2d97e-ec47d561a2c29e90-01}
2024-09-13T03:48:40.1295165Z:Activity stopped. Name = '{0}', Id = '{1}'.{PublishMessage}{00-0a5b9b74e081d09479bf7322d5b2d97e-ec47d561a2c29e90-01}
2024-09-13T03:48:40.1314323Z:Activity started. Name = '{0}', Id = '{1}'.{PublishMessage}{00-706a3ce4b0c6c457196904a867a3e0cc-52fb616820110fba-01}
2024-09-13T03:48:40.2209046Z:Activity started. Name = '{0}', Id = '{1}'.{ConsumeMessage}{00-0a5b9b74e081d09479bf7322d5b2d97e-593d0d535d9d97d4-01}
2024-09-13T03:48:40.2738128Z:Activity stopped. Name = '{0}', Id = '{1}'.{PublishMessage}{00-706a3ce4b0c6c457196904a867a3e0cc-52fb616820110fba-01}
2024-09-13T03:48:40.3615783Z:Activity stopped. Name = '{0}', Id = '{1}'.{ConsumeMessage}{00-0a5b9b74e081d09479bf7322d5b2d97e-593d0d535d9d97d4-01}
2024-09-13T03:48:40.4938106Z:Activity started. Name = '{0}', Id = '{1}'.{ConsumeMessage}{00-706a3ce4b0c6c457196904a867a3e0cc-d4f8600f3b097a2a-01}
2024-09-13T03:48:40.7048522Z:Activity stopped. Name = '{0}', Id = '{1}'.{ConsumeMessage}{00-706a3ce4b0c6c457196904a867a3e0cc-d4f8600f3b097a2a-01}
2024-09-13T03:48:42.2621686Z:Exporter failed send data to collector to {0} endpoint. Data will not be sent. Exception: {1}{http://localhost:14499/otlp/v1/traces}{System.Net.Http.HttpRequestException: Connection refused (localhost:14499)
 ---> System.Net.Sockets.SocketException (111): Connection refused
   at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token)
   at System.Net.Sockets.Socket.<ConnectAsync>g__WaitForConnectWithCancellation|285_0(AwaitableSocketAsyncEventArgs saea, ValueTask connectTask, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.ConnectToTcpHostAsync(String host, Int32 port, HttpRequestMessage initialRequest, Boolean async, CancellationToken cancellationToken)
   --- End of inner exception stack trace ---
   at System.Net.Http.HttpConnectionPool.ConnectToTcpHostAsync(String host, Int32 port, HttpRequestMessage initialRequest, Boolean async, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.AddHttp11ConnectionAsync(QueueItem queueItem)
   at System.Threading.Tasks.TaskCompletionSourceWithCancellation`1.WaitWithCancellation(CancellationToken cancellationToken)
   at System.Threading.Tasks.TaskCompletionSourceWithCancellation`1.WaitWithCancellationAsync(Boolean async, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken)
   at System.Net.Http.HttpMessageHandlerStage.Send(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.DiagnosticsHandler.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
   at System.Net.Http.HttpMessageHandlerStage.Send(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
   at System.Net.Http.SocketsHttpHandler.Send(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.HttpClient.Send(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken)
   at OpenTelemetry.Exporter.OpenTelemetryProtocol.Implementation.ExportClient.BaseOtlpHttpExportClient`1.SendExportRequest(TRequest request, DateTime deadlineUtc, CancellationToken cancellationToken)}

```

It looks like the default 14499 port for one agent to capture trace logs from OPTL is not listened on the localhost.&nbsp; Any idea about this part? Is that anything I need to do to enable it on the k8s pod?

---

<div class="post-metadata">

**Author:** ![Julius\_Loman](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/julius_loman/32/51_2.png) [@Julius\_Loman](https://community.dynatrace.com/u/Julius_Loman)\
**Post date:** [September 13, 2024, 5:58am UTC](https://community.dynatrace.com/t/is-the-possible-to-merge-service-created-by-opentelemetry-and-oneagent-as-one/47527/4 "2024-09-13T05:58:16Z")

</div>

[@xuzhao2024](https://community.dynatrace.com/user/80383)&nbsp;in Kubernetes, the EEC controller runs on the K8s node, but it’s not accessible from pods. You need to send OTLP data to ActiveGate or Cluster. See&nbsp;[OpenTelemetry trace ingest API — Dynatrace Docs](https://docs.dynatrace.com/docs/shortlink/api-otlp-traces)&nbsp;  
Depending on your DynaKube configuration in your k8s cluster, you might be able to send it through the ActiveGate running in kubernes - if it’s deployed in your setup, and you have dataingest enabled. By default the embedded activegate in k8s is reachable under [https://\<dynakubename\>.dynatrace:443](https://community.dynatrace.com/)&nbsp;, but by default it has the self-signed certificate, so you have to configure it properly either on the ActiveGate (in DynaKube, see [this](https://docs.dynatrace.com/docs/shortlink/dto-params-k8s#spec-activegate) and [this](https://docs.dynatrace.com/docs/shortlink/network-restricted-environments#tls-certificate)) or on the exporter.

Anyway - your issue is from double instrumentation and I believe you will end up with two services anyway. Services of different types can’t be merged. You need to decide if you want to do it using Dynatrace instrumentation (custom services in your case) or OpenTelemetry.

---

<div class="post-metadata">

**Author:** ![Peter\_Youssef](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/peter_youssef/32/14668_2.png) [@Peter\_Youssef](https://community.dynatrace.com/u/Peter_Youssef)\
**Post date:** [September 25, 2024, 2:52pm UTC](https://community.dynatrace.com/t/is-the-possible-to-merge-service-created-by-opentelemetry-and-oneagent-as-one/47527/5 "2024-09-25T14:52:47Z")

</div>

Hi&nbsp;[@xuzhao2024](https://community.dynatrace.com/user/80383)

- If the services are of the main type: create a service detection rule.
- In previous Dynatrace versions, there was a service merging rules, currently not available.
- If these services aren’t of the same type: Can’t be merged.
- Depending on the actual deployment of K8s, you should send the Opentelemetry data to the same end point where pods and AG are connected.
- You can apply a simple change in the Opentelemetry configuration, make sure it’s sending the data to either cluster or ActiveGates.

 ![Peter_Youssef_0-1727275274937.png](https://global.discourse-cdn.com/dynatrace/original/2X/5/53e14b648140d30276eea1205e0772012398417f.png)

You can unify the communication configurations between **K8s** and **Opentelemetry** to ensure the ingested data is correlated without more configurations.

Regards,
