# How span.type is setting if using OTel exporter?

**URL:** <https://discuss.elastic.co/t/how-span-type-is-setting-if-using-otel-exporter/314302>\
**Category:** APM\
**Tags:** go, open-telemetry\
**Created:** [September 13, 2022, 2:12pm UTC](https://discuss.elastic.co/t/how-span-type-is-setting-if-using-otel-exporter/314302 "2022-09-13T14:12:02Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![gvencadze](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gvencadze/32/104790_2.png) [@gvencadze](https://discuss.elastic.co/u/gvencadze)\
**Post date:** [September 13, 2022, 2:12pm UTC](https://discuss.elastic.co/t/how-span-type-is-setting-if-using-otel-exporter/314302/1 "2022-09-13T14:12:02Z")

</div>

Hey, I'm trying to send traces over opentelemetry library and send them to Elastic APM (v7.17) via exporter.

I saw that there is field in metadata that's called `span.type`, while using apm-go-agent, I can set value for this field, but in OTel spans I can't.

So, the question is from where does APM gets this `span.type` and how to replace it to my own value.

I tried googling but didn't find something that could help me

---

<div class="post-metadata">

**Author:** ![gvencadze](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gvencadze/32/104790_2.png) [@gvencadze](https://discuss.elastic.co/u/gvencadze)\
**Post date:** [September 19, 2022, 8:13am UTC](https://discuss.elastic.co/t/how-span-type-is-setting-if-using-otel-exporter/314302/2 "2022-09-19T08:13:42Z")

</div>

Hey @axw, sorry for tagging, maybe you know the answer? Or somebody who know?

I want to see colored spans like if I use apm-go-agent

---

<div class="post-metadata">

**Author:** ![axw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/axw/32/28197_2.png) [@axw](https://discuss.elastic.co/u/axw)\
**Post date:** [September 20, 2022, 2:38am UTC](https://discuss.elastic.co/t/how-span-type-is-setting-if-using-otel-exporter/314302/3 "2022-09-20T02:38:12Z")

</div>

@gvencadze OTel does not have a concept of "span type", so it's not currently possible to specify it explicitly. We do infer the `span.type` value from OTel semantic convention attributes. For example, if your OTel span has `db.*` attributes, then we'll set the span type to "db".

Can you give an example of a span where you would like to explicitly set the span type? Maybe we can find an alternative, such as expanding the inference logic.

---

<div class="post-metadata">

**Author:** ![gvencadze](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gvencadze/32/104790_2.png) [@gvencadze](https://discuss.elastic.co/u/gvencadze)\
**Post date:** [September 21, 2022, 11:54am UTC](https://discuss.elastic.co/t/how-span-type-is-setting-if-using-otel-exporter/314302/4 "2022-09-21T11:54:18Z")

</div>

@axw  
I've take a look, and I would like to see http/grpc calls to different systems in different colors. For now, using `apm-go-agent` I'm setting span type to `http:firstSvc` and `http:secondSvc` and it helps me to understand what exactly was done during span much faster. For example, I know that firstSvc is colored blue and second is red, so I can skip transactions without red span or something like that

I'm not sure that current way for setting span.type is correct, so maybe I shouldn't write service name after http/grpc, If you can provide a link to some docs/books/etc about making better observability I would appreciate

---

<div class="post-metadata">

**Author:** ![axw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/axw/32/28197_2.png) [@axw](https://discuss.elastic.co/u/axw)\
**Post date:** [September 23, 2022, 1:49am UTC](https://discuss.elastic.co/t/how-span-type-is-setting-if-using-otel-exporter/314302/5 "2022-09-23T01:49:38Z")

</div>

@gvencadze thanks for the context.

> I'm not sure that current way for setting span.type is correct, so maybe I shouldn't write service name after http/grpc, If you can provide a link to some docs/books/etc about making better observability I would appreciate

This isn't how `span.type` is intended to be used; its value generally shouldn't be changed. I don't think we're _currently_ doing anything special with `span.type`, but in the future we might for example render the UI a bit differently for spans with `span.type: external` and `span.subtype: http`.

> I'm not sure that current way for setting span.type is correct, so maybe I shouldn't write service name after http/grpc, If you can provide a link to some docs/books/etc about making better observability I would appreciate

I'm not aware of any specific docs to point at for the problem you're trying to solve. I will bring this thread to the attention of the rest of the APM team, in case they have any suggestions.

---

<div class="post-metadata">

**Author:** ![gvencadze](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gvencadze/32/104790_2.png) [@gvencadze](https://discuss.elastic.co/u/gvencadze)\
**Post date:** [September 23, 2022, 8:25am UTC](https://discuss.elastic.co/t/how-span-type-is-setting-if-using-otel-exporter/314302/6 "2022-09-23T08:25:49Z")

</div>

@axw I've suggestion to make colors based not on `span.type` or `span.subtype`, instead of this maybe use `span.destination.service.resource`? I think it should resolve my problem and it's good enhancement for APM at all

---

<div class="post-metadata">

**Author:** ![axw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/axw/32/28197_2.png) [@axw](https://discuss.elastic.co/u/axw)\
**Post date:** [September 23, 2022, 10:51am UTC](https://discuss.elastic.co/t/how-span-type-is-setting-if-using-otel-exporter/314302/7 "2022-09-23T10:51:49Z")

</div>

@gvencadze yes, I had the same thought, and passed the suggestion (and a link to this thread) to the APM UI team.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 14, 2022, 6:52am UTC](https://discuss.elastic.co/t/how-span-type-is-setting-if-using-otel-exporter/314302/8 "2022-10-14T06:52:36Z")

</div>

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.
