# ElasticAPMSpanId does not show up

**URL:** <https://discuss.elastic.co/t/elasticapmspanid-does-not-show-up/274879>\
**Category:** APM\
**Tags:** dotnet\
**Created:** [June 3, 2021, 1:50pm UTC](https://discuss.elastic.co/t/elasticapmspanid-does-not-show-up/274879 "2021-06-03T13:50:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![NoviceESCoder](https://avatars.discourse-cdn.com/v4/letter/n/ec9cab/32.png) [@NoviceESCoder](https://discuss.elastic.co/u/NoviceESCoder)\
**Post date:** [June 3, 2021, 1:50pm UTC](https://discuss.elastic.co/t/elasticapmspanid-does-not-show-up/274879/1 "2021-06-03T13:50:55Z")

</div>

I have installed the NuGet package `Elastic.Apm.SerilogEnricher` to my [asp.net](http://asp.net) core web app (mvc) project. My application is using Serilog to write logs directly to elasticsearch. When I added this NuGet [package](https://github.com/elastic/ecs-dotnet/blob/master/src/Elastic.Apm.SerilogEnricher/readme.md) it tells me that it will include 3 properties. 1) `ElasticApmTraceId` 2) `ElasticApmTransactionId` 3) `ElasticApmSpanId`. On my application I added `.Enrich.WithElasticApmCorrelationInfo()` inside of my `.UseSerilog()`, I run the application perform operations on it. Then when I go to the CLI in Kibana and do a DSL query search I get all the logs back, however when trying to search for `ElasticApmSpanId` it is no where to be found. I only see `ElasticApmTraceId` and `ElasticApmTransactionId`. Am I using this package incorrectly?

Inside of my `Program.cs` file:

```
public static IHostBuilder CreateHostBuilder(string[] args) =>
            Host.CreateDefaultBuilder(args)
                .UseSerilog((context, configuration) =>
                {
                    configuration.Enrich.FromLogContext()
                        .Enrich.WithElasticApmCorrelationInfo()
                        .Enrich.WithMachineName()
                        .WriteTo.Console()
                        .WriteTo.Elasticsearch(new ElasticsearchSinkOptions(new Uri(context.Configuration["ElasticConfiguration:Uri"]))
                        {
                            IndexFormat = $"{context.Configuration["ApplicationName"]}-logs-{context.HostingEnvironment.EnvironmentName?.ToLower().Replace(".", "-")}-{DateTime.UtcNow:yyyy-MM}",
                            AutoRegisterTemplate = true
                        })
                        .Enrich.WithProperty("Environment", context.HostingEnvironment.EnvironmentName)
                        .ReadFrom.Configuration(context.Configuration);
                })
                .ConfigureWebHostDefaults(webBuilder =>
                {
                    webBuilder.UseStartup<Startup>();
                })
                .UseAllElasticApm();

```

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/6/8/687ebfe1b5bac89eb97befb39679f3e977642f2e.png)

When I try to search the entire logs for `ElasticApmSpanId`:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/5/7/57f3d5eb52726fc3d51bb07e8d6fd8e58b848e17.png)

---

<div class="post-metadata">

**Author:** ![GregKalapos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gregkalapos/32/37205_2.png) [@GregKalapos](https://discuss.elastic.co/u/GregKalapos)\
**Post date:** [June 4, 2021, 2:56pm UTC](https://discuss.elastic.co/t/elasticapmspanid-does-not-show-up/274879/2 "2021-06-04T14:56:52Z")

</div>

@NoviceESCoder this is very likely because [there is no active span when the log event is generated](https://github.com/elastic/ecs-dotnet/blob/master/src/Elastic.Apm.SerilogEnricher/ElasticApmEnricher.cs#L28).

These 3 fields are added when there are active APM events.`traceid` and `transactionid` is present when there is an active APM Transaction, `spanid` is only added when there is an active span. An APM transaction is for example in [ASP.NET](http://ASP.NET) Core an HTTP request - so the transaction starts when the HTTP request hits the [ASP.NET](http://ASP.NET) Core pipeline and ends when a response is sent back. Now, a span is some action within the transaction - e.g. an outgoing HTTP call, a call to a database, a call to Elasticsearch, or some span [started manually with the Agent API](https://www.elastic.co/guide/en/apm/agent/dotnet/current/public-api.html#api-transaction-create-span).

The APM-Log correlation in Kibana right now is mainly based on the transaction id - so with the missing `spanid` you won't really miss any functionality. But even if there would be some other functionality based on this field - it still is normal and would be expected that the field is not present on the log event when there is no active transaction.

[This part of our docs](https://www.elastic.co/guide/en/apm/get-started/current/transactions.html) is a good start to understand the APM data model and learn about what a transaction and what a span is.

---

<div class="post-metadata">

**Author:** ![NoviceESCoder](https://avatars.discourse-cdn.com/v4/letter/n/ec9cab/32.png) [@NoviceESCoder](https://discuss.elastic.co/u/NoviceESCoder)\
**Post date:** [June 4, 2021, 8:18pm UTC](https://discuss.elastic.co/t/elasticapmspanid-does-not-show-up/274879/3 "2021-06-04T20:18:08Z")

</div>

I was not aware of this with the span id, but it is definitely making a lot of sense why it is not populating. Thank you for providing me with this clarification and documentations!

---

<div class="post-metadata">

**Author:** ![forloop](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/forloop/32/9021_2.png) [@forloop](https://discuss.elastic.co/u/forloop)\
**Post date:** [June 7, 2021, 4:30am UTC](https://discuss.elastic.co/t/elasticapmspanid-does-not-show-up/274879/4 "2021-06-07T04:30:53Z")

</div>

In addition to @GregKalapos answer, note that `ElasticApmSpanId` is included in 1.6.0-alpha1 package version onwards. See the release notes for more details

> **[Release 1.6.0-alpha1 · elastic/ecs-dotnet](https://github.com/elastic/ecs-dotnet/releases/tag/1.6.0-alpha1)**
>
> //github.com/elastic/ecs-dotnet/releases/tag/1.6.0-alpha1

---

<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:** [June 28, 2021, 12:30am UTC](https://discuss.elastic.co/t/elasticapmspanid-does-not-show-up/274879/5 "2021-06-28T00:30:56Z")

</div>

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