# Set template name for elastic\_otel

**URL:** <https://discuss.elastic.co/t/set-template-name-for-elastic-otel/368697>\
**Category:** APM\
**Tags:** java\
**Created:** [October 11, 2024, 5:59pm UTC](https://discuss.elastic.co/t/set-template-name-for-elastic-otel/368697 "2024-10-11T17:59:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dbalijapalli0264](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dbalijapalli0264/32/138058_2.png) [@dbalijapalli0264](https://discuss.elastic.co/u/dbalijapalli0264)\
**Post date:** [October 11, 2024, 5:59pm UTC](https://discuss.elastic.co/t/set-template-name-for-elastic-otel/368697/1 "2024-10-11T17:59:14Z")

</div>

**Kibana version** : 8.15.0

**Elasticsearch version** : 8.15.0

**APM Server version** : 8.15.0

**APM Agent language and version** : Elastic-otel-Java agent ; jar file , Release 1.0.0

**Original install method (e.g. download page, yum, deb, from source, etc.) and version**: elastic-otel-agentextension/1.0.0

**Fresh install or upgraded from other version?** : Elastic\_otel is Fresh Install, but we have elastic APM for a while that we are running without issues.

**Is there anything special in your setup?** For example, are you using the Logstash or Kafka outputs? Are you using a load balancer in front of the APM Servers? Have you changed index pattern, generated custom templates, changed agent configuration etc. : NO

**Description of the problem including expected versus actual behavior. Please include screenshots (if relevant)**:  
In elastic APM we had these public API of the Elastic APM Java agent to manually set the Transactions and spans. And allowing us to set transaction name.

Docvument for reference: [Public API | APM Java agent](https://www.elastic.co/guide/en/apm/agent/java/current/public-api.html#api-tracer-api)

# Is there any similar document that we can follow to set template name for the elastic\_OTEL java agent?

Another question: Is there a way to group all the transaction URL's into the controller's (Such as Documentcontroller, serverstatusController etc) instead of them showing as individual URL's in the transactions? )

# ![Screenshot 2024-10-11 at 1.13.51 PM](https://us1.discourse-cdn.com/elastic/original/3X/8/4/843e727f1a7781897e97f7504454fff3fbf641dc.png)

---

<div class="post-metadata">

**Author:** ![Sergey\_Kleyman](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sergey_kleyman/32/39333_2.png) [@Sergey\_Kleyman](https://discuss.elastic.co/u/Sergey_Kleyman)\
**Post date:** [October 11, 2024, 6:38pm UTC](https://discuss.elastic.co/t/set-template-name-for-elastic-otel/368697/2 "2024-10-11T18:38:15Z")

</div>

Hi @dbalijapalli0264

Please take a look at [transaction\_name\_groups](https://www.elastic.co/guide/en/apm/agent/java/current/config-core.html#config-transaction-name-groups) configuration option.

---

<div class="post-metadata">

**Author:** ![Jonas\_Kunz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jonas_kunz/32/110740_2.png) [@Jonas\_Kunz](https://discuss.elastic.co/u/Jonas_Kunz)\
**Post date:** [October 14, 2024, 1:37pm UTC](https://discuss.elastic.co/t/set-template-name-for-elastic-otel/368697/3 "2024-10-14T13:37:32Z")

</div>

> [@dbalijapalli0264](#):
>
> In elastic APM we had these public API of the Elastic APM Java agent to manually set the Transactions and spans. And allowing us to set transaction name.

You can use the [OpenTelemetry API](https://opentelemetry.io/docs/languages/java/) for that purpose, e.g.:

```auto
Span.current().updateName("foobar")

```

> Another question: Is there a way to group all the transaction URL's into the controller's (Such as Documentcontroller, serverstatusController etc) instead of them showing as individual URL's in the transactions? )

For the classic agent please have a look at the option my colleague sent.  
For the OpenTelemetry agent, you will have to manually rename your transactions using the method above.

You could enable `Dotel.instrumentation.common.experimental.controller-telemetry.enabled=true`, but that will give you only an extra span as child of the transaction corresponding to the controller method, which I think is not exactly what you want.

---

<div class="post-metadata">

**Author:** ![dbalijapalli0264](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dbalijapalli0264/32/138058_2.png) [@dbalijapalli0264](https://discuss.elastic.co/u/dbalijapalli0264)\
**Post date:** [October 15, 2024, 2:35pm UTC](https://discuss.elastic.co/t/set-template-name-for-elastic-otel/368697/4 "2024-10-15T14:35:33Z")

</div>

Thank you Surgey\_kleyman and Jonas\_kiunz,

> Span.current().updateName("foobar")  
> Could you point me to the exact document that has this example for span.current().updateName("foobar") or documentation? We already have the classic agent and it works, we are trying to experiment the elastic\_otel agent now.

> For the OpenTelemetry agent, you will have to manually rename your transactions using the method above.  
> From what you mentioned here, it looks like in opentelemetry, we rename spans and not transactions, (like we did in the classic elastic agent)

```auto
example of what we did for the classic agent transaction renaming.
Transaction transaction = ElasticApm.startTransaction();
try {
    transaction.setName("MyController#myAction");
    transaction.setType(Transaction.TYPE_REQUEST);
    // do your thing...
}
refer: https://www.elastic.co/guide/en/apm/agent/java/current/public-api.html#api-tracer-api

```

---

<div class="post-metadata">

**Author:** ![Jonas\_Kunz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jonas_kunz/32/110740_2.png) [@Jonas\_Kunz](https://discuss.elastic.co/u/Jonas_Kunz)\
**Post date:** [October 17, 2024, 12:56pm UTC](https://discuss.elastic.co/t/set-template-name-for-elastic-otel/368697/5 "2024-10-17T12:56:06Z")

</div>

In OpenTelemetry, there is no such concept as "transactions" - everything are spans. The Elastic backend will just take the root span and interpret it as transaction.

Regarding more documentation links: The link I provided already contains pointers to plenty of examples, for example this one:

> **[opentelemetry-java-examples/javaagent/src/main/java/io/opentelemetry/example/jav...](https://github.com/open-telemetry/opentelemetry-java-examples/tree/main/javaagent/src/main/java/io/opentelemetry/example/javagent)**
>
> Contribute to open-telemetry/opentelemetry-java-examples development by creating an account on GitHub.
