├── .dockerignore ├── .tool-versions ├── test ├── Elastic.Apm.Feature.Tests │ ├── .gitignore │ ├── Elastic.Apm.Feature.Tests.csproj │ └── README.md ├── integrations │ ├── applications │ │ ├── SampleAspNetCoreApp │ │ │ ├── wwwroot │ │ │ │ ├── js │ │ │ │ │ ├── site.min.js │ │ │ │ │ └── site.js │ │ │ │ ├── favicon.ico │ │ │ │ ├── lib │ │ │ │ │ ├── bootstrap │ │ │ │ │ │ └── dist │ │ │ │ │ │ │ ├── fonts │ │ │ │ │ │ │ ├── glyphicons-halflings-regular.eot │ │ │ │ │ │ │ ├── glyphicons-halflings-regular.ttf │ │ │ │ │ │ │ ├── glyphicons-halflings-regular.woff │ │ │ │ │ │ │ └── glyphicons-halflings-regular.woff2 │ │ │ │ │ │ │ └── js │ │ │ │ │ │ │ └── npm.js │ │ │ │ │ ├── jquery-validation-unobtrusive │ │ │ │ │ │ ├── .bower.json │ │ │ │ │ │ └── LICENSE.txt │ │ │ │ │ └── jquery │ │ │ │ │ │ └── .bower.json │ │ │ │ └── css │ │ │ │ │ └── site.min.css │ │ │ ├── _ViewStart.cshtml │ │ │ ├── Views │ │ │ │ ├── _ViewImports.cshtml │ │ │ │ ├── Home │ │ │ │ │ ├── Privacy.cshtml │ │ │ │ │ ├── CookiePage.cshtml │ │ │ │ │ ├── SimplePage.cshtml │ │ │ │ │ ├── AddSampleData.cshtml │ │ │ │ │ └── DistributedTracingMiniSample.cshtml │ │ │ │ ├── Account │ │ │ │ │ ├── Login.cshtml │ │ │ │ │ └── Register.cshtml │ │ │ │ └── Shared │ │ │ │ │ └── _LoginPartial.cshtml │ │ │ ├── appsettings.Development.json │ │ │ ├── Areas │ │ │ │ ├── MyArea │ │ │ │ │ ├── Views │ │ │ │ │ │ └── Home │ │ │ │ │ │ │ └── Index.cshtml │ │ │ │ │ └── Controllers │ │ │ │ │ │ └── HomeController.cs │ │ │ │ └── MyOtherArea │ │ │ │ │ ├── Views │ │ │ │ │ └── Home │ │ │ │ │ │ └── Index.cshtml │ │ │ │ │ └── Controllers │ │ │ │ │ └── HomeController.cs │ │ │ ├── Data │ │ │ │ ├── SampleData.cs │ │ │ │ └── SampleDataContext.cs │ │ │ ├── Models │ │ │ │ └── ErrorViewModel.cs │ │ │ ├── appsettings.json │ │ │ └── Program.cs │ │ ├── HostingTestApp │ │ │ └── appsettings.json │ │ ├── WebApiSample │ │ │ ├── appsettings.Development.json │ │ │ ├── WebApiSample.csproj │ │ │ ├── appsettings.json │ │ │ └── Program.cs │ │ └── SampleConsoleNetCoreApp │ │ │ ├── appsettings.json │ │ │ └── SampleConsoleNetCoreApp.csproj │ ├── Elastic.Apm.AspNetCore.Static.Tests │ │ └── TestConfigs │ │ │ └── appsettings_agentdisabled.json │ ├── Elastic.Apm.StaticImplicitInitialization.Tests │ │ └── Elastic.Apm.StaticImplicitInitialization.Tests.csproj │ ├── Elastic.Apm.AspNetCore.Tests │ │ └── TestConfigs │ │ │ ├── appsettings_invalid.json │ │ │ └── appsettings_valid.json │ ├── Elastic.Apm.Extensions.Tests.Shared │ │ └── Elastic.Apm.Extensions.Tests.Shared.csproj │ ├── Elastic.Apm.StaticExplicitInitialization.Tests │ │ └── Elastic.Apm.StaticExplicitInitialization.Tests.csproj │ ├── Elastic.Apm.Extensions.Hosting.Tests │ │ └── Elastic.Apm.Extensions.Hosting.Tests.csproj │ └── Elastic.Apm.Extensions.Logging.Tests │ │ └── Elastic.Apm.Extensions.Logging.Tests.csproj ├── azure │ ├── applications │ │ ├── Elastic.AzureFunctionApp.InProcess │ │ │ ├── host.json │ │ │ ├── Properties │ │ │ │ ├── serviceDependencies.json │ │ │ │ └── serviceDependencies.local.json │ │ │ ├── local.settings.json │ │ │ └── Startup.cs │ │ ├── Elastic.AzureFunctionApp.Isolated │ │ │ ├── host.json │ │ │ ├── Program.cs │ │ │ └── local.settings.json │ │ └── Elastic.Apm.AzureFunctionApp.Core │ │ │ ├── Elastic.Apm.AzureFunctionApp.Core.csproj │ │ │ └── Program.cs │ ├── Elastic.Apm.Azure.CosmosDb.Tests │ │ └── DocumentItem.cs │ ├── Elastic.Apm.Azure.Functions.Tests │ │ └── Elastic.Apm.Azure.Functions.Tests.csproj │ └── Elastic.Apm.Azure.ServiceBus.Tests │ │ └── Elastic.Apm.Azure.ServiceBus.Tests.csproj ├── startuphook │ ├── Elastic.Apm.StartupHook.Sample │ │ ├── Views │ │ │ ├── _ViewStart.cshtml │ │ │ ├── _ViewImports.cshtml │ │ │ ├── Home │ │ │ │ ├── Privacy.cshtml │ │ │ │ └── Index.cshtml │ │ │ └── Shared │ │ │ │ └── _ValidationScriptsPartial.cshtml │ │ ├── wwwroot │ │ │ ├── favicon.ico │ │ │ ├── js │ │ │ │ └── site.js │ │ │ └── lib │ │ │ │ └── jquery-validation-unobtrusive │ │ │ │ └── LICENSE.txt │ │ ├── appsettings.Development.json │ │ ├── appsettings.json │ │ ├── Elastic.Apm.StartupHook.Sample.csproj │ │ ├── Models │ │ │ └── ErrorViewModel.cs │ │ └── Program.cs │ └── Elastic.Apm.StartupHook.Tests │ │ └── Elastic.Apm.StartupHook.Tests.csproj ├── iis │ ├── AspNetFullFrameworkSampleApp │ │ ├── Views │ │ │ ├── _ViewStart.cshtml │ │ │ ├── Home │ │ │ │ ├── Cookies.cshtml │ │ │ │ ├── About.cshtml │ │ │ │ └── Contact.cshtml │ │ │ ├── Account │ │ │ │ ├── ForgotPasswordConfirmation.cshtml │ │ │ │ ├── ConfirmEmail.cshtml │ │ │ │ ├── ResetPasswordConfirmation.cshtml │ │ │ │ └── ForgotPassword.cshtml │ │ │ ├── Shared │ │ │ │ ├── Error.cshtml │ │ │ │ └── _LoginPartial.cshtml │ │ │ └── Database │ │ │ │ ├── Index.cshtml │ │ │ │ └── Create.cshtml │ │ ├── Areas │ │ │ └── MyArea │ │ │ │ ├── _ViewStart.cshtml │ │ │ │ ├── Controllers │ │ │ │ └── HomeController.cs │ │ │ │ └── MyAreaRegistration.cs │ │ ├── favicon.ico │ │ ├── Asmx │ │ │ ├── Health.asmx │ │ │ └── Health.asmx.cs │ │ ├── Global.asax │ │ ├── Bootstrap │ │ │ └── AlertStatus.cs │ │ ├── WebformsException.aspx.cs │ │ ├── Mvc │ │ │ └── JsonBadRequestResult.cs │ │ ├── Consts.cs │ │ ├── Models │ │ │ ├── CreateSampleDataViewModel.cs │ │ │ ├── ApplicationUser.cs │ │ │ ├── ForgotPasswordViewModel.cs │ │ │ ├── DiagnosticsViewModel.cs │ │ │ └── LoginViewModel.cs │ │ ├── App_Start │ │ │ └── FilterConfig.cs │ │ ├── Content │ │ │ └── Site.css │ │ ├── Data │ │ │ └── SampleData.cs │ │ ├── WebformsException.aspx │ │ ├── Extensions │ │ │ └── TempDataExtensions.cs │ │ ├── Services │ │ │ └── Auth │ │ │ │ └── ApplicationSignInManager.cs │ │ └── ActionFilters │ │ │ └── RedirectIfAuthenticatedAttribute.cs │ ├── Elastic.Apm.FullFramework.Tests │ │ └── Elastic.Apm.FullFramework.Tests.csproj │ └── Elastic.Apm.AspNetFullFramework.Tests │ │ ├── AspNetFullFrameworkFact.cs │ │ ├── AspNetFullFrameworkTheory.cs │ │ ├── MetricsWithAccessToPerfCountersTests.cs │ │ └── MetricsWithoutAccessToPerfCountersTests.cs ├── Elastic.Apm.Tests.MockApmServer │ ├── cert.pfx │ ├── appsettings.json │ ├── appsettings.Development.json │ ├── MetricSampleDto.cs │ ├── IDto.cs │ ├── ITimedDto.cs │ ├── ITimestampedDto.cs │ ├── SpanLinkDto.cs │ ├── CompositeDto.cs │ ├── SpanCountDto.cs │ └── DroppedSpanStatsDto.cs ├── xunit.runner.json ├── instrumentations │ ├── Elastic.Apm.MongoDb.Tests │ │ ├── LICENSE │ │ ├── Elastic.Apm.MongoDb.Tests.csproj │ │ └── Fixture │ │ │ └── IMongoConfiguration.cs │ ├── grpc │ │ ├── GrpcServiceSample │ │ │ ├── appsettings.Development.json │ │ │ ├── appsettings.json │ │ │ ├── GrpcServiceSample.csproj │ │ │ ├── Protos │ │ │ │ └── greet.proto │ │ │ ├── Program.cs │ │ │ └── Services │ │ │ │ └── GreeterService.cs │ │ └── GrpcClientSample │ │ │ └── GrpcClientSample.csproj │ ├── Elastic.Apm.Docker.Tests │ │ └── Elastic.Apm.Docker.Tests.csproj │ ├── Elastic.Apm.SqlClient.Tests │ │ └── SqlServerCollection.cs │ ├── Elastic.Apm.StackExchange.Redis.Tests │ │ ├── ConnectionMultiplexerExtensionTests.cs │ │ └── Elastic.Apm.StackExchange.Redis.Tests.csproj │ ├── Elastic.Clients.Elasticsearch.Tests │ │ └── README.md │ └── Elastic.Apm.Elasticsearch.Tests │ │ └── Elastic.Apm.Elasticsearch.Tests.csproj ├── .runsettings ├── profiler │ ├── applications │ │ ├── Elastic.Apm.AdoNet.NetStandard │ │ │ └── Elastic.Apm.AdoNet.NetStandard.csproj │ │ ├── MySqlDataSample │ │ │ └── MySqlDataSample.csproj │ │ ├── RabbitMqSample │ │ │ └── RabbitMqSample.csproj │ │ ├── SatelliteAssemblySample │ │ │ ├── SatelliteAssemblySample.csproj │ │ │ └── Program.cs │ │ ├── Elastic.Apm.AdoNet │ │ │ └── Elastic.Apm.AdoNet.csproj │ │ ├── OracleManagedDataAccessSample │ │ │ └── OracleManagedDataAccessSample.csproj │ │ ├── OracleManagedDataAccessCoreSample │ │ │ └── OracleManagedDataAccessCoreSample.csproj │ │ ├── NpgsqlSample │ │ │ └── NpgsqlSample.csproj │ │ ├── KafkaSample │ │ │ ├── KafkaSample.csproj │ │ │ └── SampleMessage.cs │ │ ├── SqliteSample │ │ │ └── SqliteSample.csproj │ │ └── SqlClientSample │ │ │ └── SqlClientSample.csproj │ └── Elastic.Apm.Profiler.Managed.Tests │ │ └── DuckTyping │ │ ├── Methods │ │ └── ProxiesDefinitions │ │ │ ├── IDictioValue.cs │ │ │ └── TestEnum2.cs │ │ └── Properties │ │ ├── ValueType │ │ └── ProxiesDefinitions │ │ │ ├── IObscureErrorDuckType.cs │ │ │ └── IObscureStaticErrorDuckType.cs │ │ ├── ReferenceType │ │ └── ProxiesDefinitions │ │ │ ├── IObscureErrorDuckType.cs │ │ │ └── IObscureStaticErrorDuckType.cs │ │ └── TypeChaining │ │ └── ProxiesDefinitions │ │ ├── IObscureErrorDuckType.cs │ │ └── IObscureStaticErrorDuckType.cs ├── Elastic.Apm.Tests.Utilities │ ├── ILineWriter.cs │ ├── FluentAssertionsUtils.cs │ ├── FakeMetricsCollector.cs │ ├── NoopCentralConfigurationFetcher.cs │ ├── Azure │ │ └── AzureResourceException.cs │ ├── ApmAgentTestExtensions.cs │ ├── XUnit │ │ ├── DisabledOnWindowsTheory.cs │ │ └── MemberData.cs │ ├── NoopCurrentExecutionSegmentsContainer.cs │ ├── NoopLogger.cs │ ├── EnumerableTestExtensions.cs │ ├── ThreadSafeIntCounter.cs │ ├── ThreadSafeLongCounter.cs │ ├── FlushingTextWriterToLoggerAdaptor.cs │ ├── SplittingLineWriter.cs │ ├── DummyTestException.cs │ ├── SystemDiagnosticsTraceLineWriter.cs │ ├── LocalPort.cs │ ├── TestEnvironmentVariables.cs │ ├── TestHostNameDetector.cs │ ├── ToAllSinksLogger.cs │ ├── XunitOutputToLineWriterAdaptor.cs │ ├── FlushingTextWriterToLineWriterAdaptor.cs │ └── IntExtensions.cs ├── opentelemetry │ ├── OpenTelemetrySample │ │ ├── OpenTelemetrySample.csproj │ │ └── Program.cs │ └── Elastic.Apm.OpenTelemetry.Tests │ │ └── Elastic.Apm.OpenTelemetry.Tests.csproj └── Elastic.Apm.Tests │ ├── HelpersTests │ ├── DbgUtilsTests.cs │ ├── LazyContextualInitTestsHelpers.cs │ └── CollectionExtensionsTests.cs │ └── Utilities │ └── AgentFeaturesProviderScope.cs ├── .github ├── .editorconfig ├── labeler-config.yml ├── .github.csproj ├── workflows │ ├── docs-cleanup.yml │ ├── github-commands-comment.yml │ ├── docs-build.yml │ └── test-reporter.yml ├── ISSUE_TEMPLATE │ └── config.yml └── dependabot.yml ├── .ci └── updatecli │ └── values.d │ ├── update-compose.yml │ ├── apm-data-spec.yml │ ├── apm-gherkin.yml │ ├── apm-json-specs.yml │ └── scm.yml ├── .rustfmt.toml ├── docs ├── release-notes │ └── toc.yml ├── reference │ ├── images │ │ ├── unblock-profiler-dll.png │ │ ├── azure-functions-configuration.png │ │ └── dynamic-config.svg │ └── setup-azure-cosmosdb.md ├── docs.csproj └── docset.yml ├── sample ├── ApiSamples │ ├── README.md │ └── ApiSamples.csproj ├── WebApiExample │ ├── appsettings.Development.json │ ├── appsettings.json │ ├── WeatherForecast.cs │ ├── Program.cs │ ├── Controllers │ │ ├── ErrorController.cs │ │ └── WeatherForecastController.cs │ └── WebApiExample.csproj ├── WorkerServiceSample │ ├── appsettings.Development.json │ ├── appsettings.json │ ├── Program.cs │ ├── WorkerServiceSample.csproj │ └── Worker.cs ├── HttpListenerSample │ ├── HttpListenerSample.csproj │ └── README.md ├── Directory.Build.props ├── StackExchangeRedisSample │ └── StackExchangeRedisSample.csproj ├── Elastic.Apm.Azure.ServiceBus.Sample │ └── Elastic.Apm.Azure.ServiceBus.Sample.csproj ├── ElasticsearchSample │ └── ElasticsearchSample.csproj └── Sample.Microsoft.Data.SqlClient │ └── Sample.Microsoft.Data.SqlClient.csproj ├── global.json ├── xunit.runner.json ├── src ├── profiler │ ├── elastic_apm_profiler │ │ ├── README │ │ ├── src │ │ │ ├── cil │ │ │ │ └── mod.rs │ │ │ ├── error.rs │ │ │ └── interfaces │ │ │ │ └── imap_token.rs │ │ └── elastic_apm_profiler.csproj │ ├── Elastic.Apm.Profiler.Managed.Core │ │ └── Elastic.Apm.Profiler.Managed.Core.csproj │ ├── Elastic.Apm.Profiler.IntegrationsGenerator │ │ ├── MethodReplacement.cs │ │ ├── Wrapper.cs │ │ ├── Integration.cs │ │ ├── Elastic.Apm.Profiler.IntegrationsGenerator.csproj │ │ └── Target.cs │ └── Elastic.Apm.Profiler.Managed │ │ ├── TracerExtensions.cs │ │ ├── ExecutionSegmentExtensions.cs │ │ ├── DuckTyping │ │ └── DuckCopyAttribute.cs │ │ └── Reflection │ │ └── OpCodeValues.cs ├── instrumentations │ ├── Elastic.Apm.EntityFramework6 │ │ └── README.md │ ├── Elastic.Apm.MongoDb │ │ ├── NOTICE │ │ ├── LICENSE_LOCAL │ │ ├── EventPayload.cs │ │ └── Constants.cs │ └── Elastic.Apm.GrpcClient │ │ └── Elastic.Apm.GrpcClient.csproj ├── integrations │ ├── Elastic.Apm.AspNetFullFramework │ │ ├── README.md │ │ ├── OpenIdClaimTypes.cs │ │ └── AgentDependencies.cs │ ├── Elastic.Apm.AspNetCore │ │ └── Consts.cs │ └── Elastic.Apm.Extensions.Logging │ │ └── ApmErrorLoggingProvider.cs ├── Elastic.Apm │ ├── Helpers │ │ ├── AssertionLevel.cs │ │ ├── AssertionFailedException.cs │ │ ├── LogLevelUtils.cs │ │ ├── CollectionExtensions.cs │ │ ├── DbgUtils.cs │ │ ├── ObjectExtensions.cs │ │ ├── ContractExtensions.cs │ │ └── ExceptionFilter.cs │ ├── Config │ │ ├── IConfigurationSnapshotProvider.cs │ │ ├── IConfigurationStore.cs │ │ ├── IConfiguration.cs │ │ └── Net4FullFramework │ │ │ └── AppSettingsConfiguration.cs │ ├── BackendComm │ │ └── CentralConfig │ │ │ ├── ICentralConfigurationFetcher.cs │ │ │ ├── ICentralConfigurationResponseParser.cs │ │ │ └── CentralConfigurationKeyValue.cs │ ├── Api │ │ ├── Container.cs │ │ ├── Constraints │ │ │ └── RequiredAttribute.cs │ │ ├── Kubernetes │ │ │ ├── Node.cs │ │ │ ├── Pod.cs │ │ │ └── KubernetesMetadata.cs │ │ ├── Node.cs │ │ ├── Outcome.cs │ │ ├── MetricSample.cs │ │ ├── Database.cs │ │ ├── User.cs │ │ ├── Links.cs │ │ ├── ProcessInformation.cs │ │ └── SpecificationAttribute.cs │ ├── Libraries │ │ ├── Ben.Demystifier │ │ │ └── Enumerable │ │ │ │ └── IEnumerableIList.cs │ │ └── Newtonsoft.Json │ │ │ ├── Linq │ │ │ ├── JsonPath │ │ │ │ ├── RootFilter.cs │ │ │ │ ├── QueryFilter.cs │ │ │ │ ├── ArrayMultipleIndexFilter.cs │ │ │ │ └── QueryScanFilter.cs │ │ │ ├── MergeNullValueHandling.cs │ │ │ └── MergeArrayHandling.cs │ │ │ ├── Serialization │ │ │ └── DefaultNamingStrategy.cs │ │ │ └── JsonNameTable.cs │ ├── ServerInfo │ │ ├── ApmServerInfo.cs │ │ └── IApmServerInfo.cs │ ├── Metrics │ │ └── IMetricsCollector.cs │ ├── DiagnosticSource │ │ └── IDiagnosticsSubscriber.cs │ ├── ICurrentExecutionSegmentsContainer.cs │ ├── Logging │ │ └── LogLevelSwitch.cs │ ├── Report │ │ ├── IntakeResponse.cs │ │ └── IPayloadSender.cs │ ├── Reflection │ │ └── CascadePropertyFetcher.cs │ ├── Model │ │ ├── SpanTimerKey.cs │ │ └── OTel.cs │ ├── Cloud │ │ └── ICloudMetadataProvider.cs │ ├── Consts.cs │ └── Filters │ │ └── ErrorContextSanitizerFilter.cs ├── azure │ ├── Elastic.Apm.Azure.ServiceBus │ │ └── ServiceBus.cs │ ├── Elastic.Apm.Azure.Storage │ │ └── FileShareUrl.cs │ └── Elastic.Apm.Azure.CosmosDb │ │ └── Elastic.Apm.Azure.CosmosDb.csproj ├── Elastic.Apm.Specification │ └── Elastic.Apm.Specification.csproj └── startuphook │ └── ElasticApmAgentStartupHook │ └── ElasticApmAgentStartupHook.csproj ├── benchmarks ├── Directory.Build.props ├── Elastic.Apm.Benchmarks │ ├── TraceParentBenchmarks.cs │ └── Elastic.Apm.Benchmarks.csproj └── Elastic.Apm.Profiling │ └── Elastic.Apm.Profiling.csproj ├── SECURITY.md ├── Cargo.toml ├── dotnet-tools.json ├── Dockerfile └── coverlet.runsettings /.dockerignore: -------------------------------------------------------------------------------- 1 | * 2 | !build/output -------------------------------------------------------------------------------- /.tool-versions: -------------------------------------------------------------------------------- 1 | updatecli v0.112.0 -------------------------------------------------------------------------------- /test/Elastic.Apm.Feature.Tests/.gitignore: -------------------------------------------------------------------------------- 1 | Features/*.feature.cs -------------------------------------------------------------------------------- /.github/.editorconfig: -------------------------------------------------------------------------------- 1 | [*.yml] 2 | indent_style = space 3 | indent_size = 2 -------------------------------------------------------------------------------- /test/integrations/applications/SampleAspNetCoreApp/wwwroot/js/site.min.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.ci/updatecli/values.d/update-compose.yml: -------------------------------------------------------------------------------- 1 | spec: 2 | files: 3 | - "update-compose.yaml" -------------------------------------------------------------------------------- /.ci/updatecli/values.d/apm-data-spec.yml: -------------------------------------------------------------------------------- 1 | apm_schema_specs_path: src/Elastic.Apm.Specification/specs 2 | -------------------------------------------------------------------------------- /test/azure/applications/Elastic.AzureFunctionApp.InProcess/host.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0" 3 | } -------------------------------------------------------------------------------- /test/integrations/applications/SampleAspNetCoreApp/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } -------------------------------------------------------------------------------- /.ci/updatecli/values.d/apm-gherkin.yml: -------------------------------------------------------------------------------- 1 | apm_gherkin_specs_path: test/Elastic.Apm.Feature.Tests/Features 2 | -------------------------------------------------------------------------------- /.github/labeler-config.yml: -------------------------------------------------------------------------------- 1 | # add 'agent-dotnet' label to all new issues 2 | agent-dotnet: 3 | - '.*' 4 | -------------------------------------------------------------------------------- /.rustfmt.toml: -------------------------------------------------------------------------------- 1 | reorder_imports = true 2 | 3 | # requires nightly rustfmt 4 | imports_granularity = "Crate" -------------------------------------------------------------------------------- /test/startuphook/Elastic.Apm.StartupHook.Sample/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } -------------------------------------------------------------------------------- /docs/release-notes/toc.yml: -------------------------------------------------------------------------------- 1 | toc: 2 | - file: index.md 3 | - file: known-issues.md 4 | - file: breaking-changes.md -------------------------------------------------------------------------------- /test/iis/AspNetFullFrameworkSampleApp/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "~/Views/Shared/_Layout.cshtml"; 3 | } -------------------------------------------------------------------------------- /test/iis/AspNetFullFrameworkSampleApp/Areas/MyArea/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "~/Views/Shared/_Layout.cshtml"; 3 | } -------------------------------------------------------------------------------- /.ci/updatecli/values.d/apm-json-specs.yml: -------------------------------------------------------------------------------- 1 | apm_json_specs_path: test/Elastic.Apm.Tests.Utilities/TestResources/json-specs 2 | -------------------------------------------------------------------------------- /sample/ApiSamples/README.md: -------------------------------------------------------------------------------- 1 | # API Samples 2 | 3 | This project contains samples that use the Public Agent API for manual instrumentation. -------------------------------------------------------------------------------- /global.json: -------------------------------------------------------------------------------- 1 | { 2 | "sdk": { 3 | "version": "9.0.303", 4 | "rollForward": "latestFeature", 5 | "allowPrerelease": false 6 | } 7 | } -------------------------------------------------------------------------------- /docs/reference/images/unblock-profiler-dll.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elastic/apm-agent-dotnet/main/docs/reference/images/unblock-profiler-dll.png -------------------------------------------------------------------------------- /test/Elastic.Apm.Tests.MockApmServer/cert.pfx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elastic/apm-agent-dotnet/main/test/Elastic.Apm.Tests.MockApmServer/cert.pfx -------------------------------------------------------------------------------- /test/iis/AspNetFullFrameworkSampleApp/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elastic/apm-agent-dotnet/main/test/iis/AspNetFullFrameworkSampleApp/favicon.ico -------------------------------------------------------------------------------- /test/iis/AspNetFullFrameworkSampleApp/Asmx/Health.asmx: -------------------------------------------------------------------------------- 1 | <%@ WebService Language="C#" CodeBehind="Health.asmx.cs" Class="AspNetFullFrameworkSampleApp.Asmx.Health" %> 2 | -------------------------------------------------------------------------------- /test/iis/AspNetFullFrameworkSampleApp/Global.asax: -------------------------------------------------------------------------------- 1 | <%@ Application Codebehind="Global.asax.cs" Inherits="AspNetFullFrameworkSampleApp.MvcApplication" Language="C#" %> -------------------------------------------------------------------------------- /docs/reference/images/azure-functions-configuration.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elastic/apm-agent-dotnet/main/docs/reference/images/azure-functions-configuration.png -------------------------------------------------------------------------------- /test/iis/AspNetFullFrameworkSampleApp/Views/Home/Cookies.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewBag.Title = "Cookies"; 3 | } 4 |

@ViewBag.Title.

5 |

@ViewBag.Message

6 | -------------------------------------------------------------------------------- /xunit.runner.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://xunit.net/schema/current/xunit.runner.schema.json", 3 | "parallelizeAssembly": false, 4 | "appDomain": "denied" 5 | } -------------------------------------------------------------------------------- /test/integrations/applications/SampleAspNetCoreApp/Views/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using SampleAspNetCoreApp 2 | @using SampleAspNetCoreApp.Models 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers -------------------------------------------------------------------------------- /test/startuphook/Elastic.Apm.StartupHook.Sample/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elastic/apm-agent-dotnet/main/test/startuphook/Elastic.Apm.StartupHook.Sample/wwwroot/favicon.ico -------------------------------------------------------------------------------- /test/azure/applications/Elastic.AzureFunctionApp.InProcess/Properties/serviceDependencies.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "appInsights1": { 4 | "type": "appInsights" 5 | } 6 | } 7 | } -------------------------------------------------------------------------------- /test/integrations/applications/SampleAspNetCoreApp/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elastic/apm-agent-dotnet/main/test/integrations/applications/SampleAspNetCoreApp/wwwroot/favicon.ico -------------------------------------------------------------------------------- /docs/docs.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net8.0 4 | False 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /sample/WebApiExample/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.Hosting.Lifetime": "Information" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/profiler/elastic_apm_profiler/README: -------------------------------------------------------------------------------- 1 | Profiler auto instrumentation documentation can be found online at: 2 | 3 | https://www.elastic.co/guide/en/apm/agent/dotnet/${VERSION}/setup-auto-instrumentation.html 4 | -------------------------------------------------------------------------------- /test/azure/applications/Elastic.AzureFunctionApp.InProcess/Properties/serviceDependencies.local.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "appInsights1": { 4 | "type": "appInsights.sdk" 5 | } 6 | } 7 | } -------------------------------------------------------------------------------- /sample/WorkerServiceSample/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.Hosting.Lifetime": "Information" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/startuphook/Elastic.Apm.StartupHook.Sample/Views/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using Elastic.Apm.StartupHook.Sample 2 | @using Elastic.Apm.StartupHook.Sample.Models 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers -------------------------------------------------------------------------------- /test/xunit.runner.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://xunit.net/schema/current/xunit.runner.schema.json", 3 | "diagnosticMessages": true, 4 | "internalDiagnosticMessages": true, 5 | "longRunningTestSeconds": 2 6 | } -------------------------------------------------------------------------------- /benchmarks/Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /test/iis/AspNetFullFrameworkSampleApp/Views/Home/About.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewBag.Title = "About"; 3 | } 4 |

@ViewBag.Title.

5 |

@ViewBag.Message

6 | 7 |

Use this area to provide additional information.

-------------------------------------------------------------------------------- /test/integrations/applications/SampleAspNetCoreApp/Views/Home/Privacy.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Privacy Policy"; 3 | } 4 |

@ViewData["Title"]

5 | 6 |

Use this page to detail your site's privacy policy.

-------------------------------------------------------------------------------- /test/startuphook/Elastic.Apm.StartupHook.Sample/Views/Home/Privacy.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Privacy Policy"; 3 | } 4 |

@ViewData["Title"]

5 | 6 |

Use this page to detail your site's privacy policy.

-------------------------------------------------------------------------------- /test/iis/AspNetFullFrameworkSampleApp/Bootstrap/AlertStatus.cs: -------------------------------------------------------------------------------- 1 | namespace AspNetFullFrameworkSampleApp.Bootstrap 2 | { 3 | public enum AlertStatus 4 | { 5 | Info, 6 | Success, 7 | Danger, 8 | Warning 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/integrations/applications/HostingTestApp/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Error" 5 | } 6 | }, 7 | "ElasticApm": { 8 | "ServiceName": "TestApp" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/instrumentations/Elastic.Apm.MongoDb.Tests/LICENSE: -------------------------------------------------------------------------------- 1 | The code for Elastic.Apm.MongoDb.Tests is based on the elastic-apm-mongo project by Vadim Hatsura (@vhatsura), 2 | licensed under the Apache 2.0 License. https://github.com/vhatsura/elastic-apm-mongo -------------------------------------------------------------------------------- /test/integrations/applications/WebApiSample/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Debug", 5 | "System": "Information", 6 | "Microsoft": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /.github/.github.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net8.0 4 | False 5 | disable 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /test/integrations/applications/SampleAspNetCoreApp/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Debug", 5 | "System": "Information", 6 | "Microsoft": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/.runsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /test/Elastic.Apm.Tests.MockApmServer/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Debug", 5 | "System": "Information", 6 | "Microsoft": "Information" 7 | } 8 | }, 9 | "AllowedHosts": "*", 10 | } 11 | -------------------------------------------------------------------------------- /test/startuphook/Elastic.Apm.StartupHook.Sample/Views/Shared/_ValidationScriptsPartial.cshtml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/instrumentations/Elastic.Apm.EntityFramework6/README.md: -------------------------------------------------------------------------------- 1 | # Elastic.Apm.EntityFramework6 2 | 3 | This project contains an Entity Framework 6 (AKA classic Entity Framework) interceptor that automatically creates spans for DB operations executed by Entity Framework. 4 | -------------------------------------------------------------------------------- /test/profiler/applications/Elastic.Apm.AdoNet.NetStandard/Elastic.Apm.AdoNet.NetStandard.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/instrumentations/Elastic.Apm.MongoDb/NOTICE: -------------------------------------------------------------------------------- 1 | ========== 2 | Notice for: Elastic.Apm.MongoDb 3 | ---------- 4 | Based on the elastic-apm-mongo project by Vadim Hatsura (@vhatsura), 5 | licensed under the Apache 2.0 License. https://github.com/vhatsura/elastic-apm-mongo 6 | -------------------------------------------------------------------------------- /test/Elastic.Apm.Tests.MockApmServer/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Debug", 5 | "System": "Information", 6 | "Microsoft": "Information" 7 | } 8 | }, 9 | "AllowedHosts": "*", 10 | } 11 | -------------------------------------------------------------------------------- /test/startuphook/Elastic.Apm.StartupHook.Sample/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Trace", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/integrations/Elastic.Apm.AspNetFullFramework/README.md: -------------------------------------------------------------------------------- 1 | # Elastic.Apm.AspNetFullFramework 2 | 3 | This project contains an IIS module that automatically starts and stops transactions for incoming HTTP requests. The goal is to provide auto instrumentation for ASP.NET (classic) applications. -------------------------------------------------------------------------------- /test/azure/applications/Elastic.AzureFunctionApp.Isolated/host.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0", 3 | "logging": { 4 | "logLevel": { 5 | "default": "Debug" 6 | }, 7 | "console": { 8 | "isEnabled": true, 9 | "DisableColors": true 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /test/instrumentations/grpc/GrpcServiceSample/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Debug", 5 | "System": "Information", 6 | "Grpc": "Information", 7 | "Microsoft": "Information" 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/integrations/applications/SampleAspNetCoreApp/Areas/MyArea/Views/Home/Index.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "MyArea Home Page"; 3 | } 4 | @model List 5 | 6 |
7 | 10 | 11 | -------------------------------------------------------------------------------- /test/integrations/applications/SampleAspNetCoreApp/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elastic/apm-agent-dotnet/main/test/integrations/applications/SampleAspNetCoreApp/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /test/integrations/applications/SampleAspNetCoreApp/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elastic/apm-agent-dotnet/main/test/integrations/applications/SampleAspNetCoreApp/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /test/startuphook/Elastic.Apm.StartupHook.Sample/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Trace", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "AllowedHosts": "*" 10 | } 11 | -------------------------------------------------------------------------------- /test/integrations/applications/SampleAspNetCoreApp/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elastic/apm-agent-dotnet/main/test/integrations/applications/SampleAspNetCoreApp/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /test/integrations/applications/SampleAspNetCoreApp/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elastic/apm-agent-dotnet/main/test/integrations/applications/SampleAspNetCoreApp/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /test/startuphook/Elastic.Apm.StartupHook.Sample/Elastic.Apm.StartupHook.Sample.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0;net9.0 5 | false 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /test/integrations/Elastic.Apm.AspNetCore.Static.Tests/TestConfigs/appsettings_agentdisabled.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Warning" 5 | } 6 | }, 7 | "AllowedHosts": "*", 8 | "ElasticApm": 9 | { 10 | "Enabled": false 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/integrations/applications/SampleAspNetCoreApp/wwwroot/js/site.js: -------------------------------------------------------------------------------- 1 | // Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | // for details on configuring this project to bundle and minify static web assets. 3 | 4 | // Write your JavaScript code. 5 | -------------------------------------------------------------------------------- /test/startuphook/Elastic.Apm.StartupHook.Sample/wwwroot/js/site.js: -------------------------------------------------------------------------------- 1 | // Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | // for details on configuring this project to bundle and minify static web assets. 3 | 4 | // Write your JavaScript code. 5 | -------------------------------------------------------------------------------- /src/instrumentations/Elastic.Apm.MongoDb/LICENSE_LOCAL: -------------------------------------------------------------------------------- 1 | ========== 2 | Elastic.Apm.MongoDb 3 | ---------- 4 | 5 | The code for Elastic.Apm.MongoDb is based on the elastic-apm-mongo project by Vadim Hatsura (@vhatsura), 6 | licensed under the Apache 2.0 License. https://github.com/vhatsura/elastic-apm-mongo 7 | -------------------------------------------------------------------------------- /test/startuphook/Elastic.Apm.StartupHook.Sample/Models/ErrorViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace Elastic.Apm.StartupHook.Sample.Models 2 | { 3 | public class ErrorViewModel 4 | { 5 | public string RequestId { get; set; } 6 | 7 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /sample/WebApiExample/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Warning", 5 | "Microsoft.Hosting.Lifetime": "Information", 6 | "Elastic.Apm": "Information" 7 | } 8 | }, 9 | "ElasticApm": { 10 | "ServiceName": "WebApiSample" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/profiler/Elastic.Apm.Profiler.Managed.Core/Elastic.Apm.Profiler.Managed.Core.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net462;netstandard2.0;net8.0 5 | false 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /test/startuphook/Elastic.Apm.StartupHook.Sample/Views/Home/Index.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Home Page"; 3 | } 4 | 5 |
6 |

Welcome

7 |

Learn about building Web apps with ASP.NET Core.

8 |
-------------------------------------------------------------------------------- /.ci/updatecli/values.d/scm.yml: -------------------------------------------------------------------------------- 1 | scm: 2 | enabled: true 3 | owner: elastic 4 | repository: apm-agent-dotnet 5 | branch: main 6 | commitusingapi: true 7 | # begin update-compose policy values 8 | user: obltmachine 9 | email: obltmachine@users.noreply.github.com 10 | # end update-compose policy values 11 | -------------------------------------------------------------------------------- /sample/WorkerServiceSample/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Warning", 5 | "Microsoft.Hosting.Lifetime": "Information", 6 | "Elastic.Apm": "Information" 7 | } 8 | }, 9 | "ElasticApm": { 10 | "ServiceName": "WorkerServiceSampleApp" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/integrations/applications/SampleAspNetCoreApp/Areas/MyOtherArea/Views/Home/Index.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "MyOtherArea Home Page"; 3 | } 4 | @model List 5 | 6 |
7 | 10 | 11 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | Thanks for your interest in the security of our products. 4 | Our security policy can be found at [https://www.elastic.co/community/security](https://www.elastic.co/community/security). 5 | 6 | ## Reporting a Vulnerability 7 | Please send security vulnerability reports to security@elastic.co. 8 | -------------------------------------------------------------------------------- /sample/WebApiExample/WeatherForecast.cs: -------------------------------------------------------------------------------- 1 | namespace WebApiExample; 2 | 3 | public class WeatherForecast 4 | { 5 | public DateOnly Date { get; set; } 6 | 7 | public int TemperatureC { get; set; } 8 | 9 | public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); 10 | 11 | public string? Summary { get; set; } 12 | } 13 | -------------------------------------------------------------------------------- /test/iis/AspNetFullFrameworkSampleApp/WebformsException.aspx.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Web.UI; 3 | 4 | namespace AspNetFullFrameworkSampleApp 5 | { 6 | public partial class WebformsException : Page 7 | { 8 | protected void Page_Load(object sender, EventArgs e) => Title = nameof(WebformsException); 9 | } 10 | } 11 | 12 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | 3 | members = [ 4 | "src/profiler/elastic_apm_profiler", 5 | ] 6 | 7 | # default release profile: https://doc.rust-lang.org/cargo/reference/profiles.html#release 8 | [profile.release] 9 | lto = true 10 | codegen-units = 1 11 | # reduce binary size by not unwinding on panic to get a backtrace 12 | #panic = "abort" -------------------------------------------------------------------------------- /test/iis/AspNetFullFrameworkSampleApp/Views/Account/ForgotPasswordConfirmation.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewBag.Title = "Forgot Password Confirmation"; 3 | } 4 | 5 |
6 |

@ViewBag.Title

7 |
8 |
9 |

10 | Please check your email to reset your password. 11 |

12 |
13 | 14 | -------------------------------------------------------------------------------- /test/iis/AspNetFullFrameworkSampleApp/Views/Shared/Error.cshtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Error 6 | 7 | 8 |
9 |

Error.

10 |

An error occurred while processing your request.

11 |
12 | 13 | -------------------------------------------------------------------------------- /test/integrations/applications/SampleAspNetCoreApp/wwwroot/css/site.min.css: -------------------------------------------------------------------------------- 1 | body{padding-top:50px;padding-bottom:20px}.body-content{padding-left:15px;padding-right:15px}.carousel-caption p{font-size:20px;line-height:1.4}.carousel-inner .item img[src$=".svg"]{width:100%}#qrCode{margin:15px}@media screen and (max-width:767px){.carousel-caption{display:none}} -------------------------------------------------------------------------------- /.github/workflows/docs-cleanup.yml: -------------------------------------------------------------------------------- 1 | name: docs-cleanup 2 | 3 | on: 4 | pull_request_target: 5 | types: 6 | - closed 7 | 8 | jobs: 9 | docs-preview: 10 | uses: elastic/docs-builder/.github/workflows/preview-cleanup.yml@main 11 | permissions: 12 | contents: none 13 | id-token: write 14 | deployments: write 15 | -------------------------------------------------------------------------------- /dotnet-tools.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "isRoot": true, 4 | "tools": { 5 | "assembly-differ": { 6 | "version": "0.13.0", 7 | "commands": [ 8 | "assembly-differ" 9 | ] 10 | }, 11 | "minver-cli": { 12 | "version": "6.0.0", 13 | "commands": [ 14 | "minver" 15 | ] 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | 2 | blank_issues_enabled: true 3 | contact_links: 4 | - name: Question 5 | url: https://discuss.elastic.co/c/apm 6 | about: Ask (and answer) questions here. 7 | - name: Security Vulnerability 8 | url: https://www.elastic.co/community/security 9 | about: Send security vulnerability reports to security@elastic.co. -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM mcr.microsoft.com/dotnet/sdk:6.0 2 | RUN mkdir /usr/agent 3 | ARG AGENT_ZIP_FILE 4 | COPY ${AGENT_ZIP_FILE} /usr/agent/apm-dotnet-agent.zip 5 | 6 | RUN apt-get -qq update 7 | RUN apt-get -qq -y --no-install-recommends install unzip \ 8 | && rm -rf /var/lib/apt/lists/* 9 | 10 | RUN unzip /usr/agent/apm-dotnet-agent.zip -d /usr/agent/apm-dotnet-agent -------------------------------------------------------------------------------- /docs/docset.yml: -------------------------------------------------------------------------------- 1 | project: 'APM .NET agent docs' 2 | products: 3 | - id: apm-agent 4 | cross_links: 5 | - apm-agent-rum-js 6 | - beats 7 | - docs-content 8 | - ecs 9 | - ecs-dotnet 10 | - ecs-logging 11 | - elasticsearch 12 | - elastic-otel-dotnet 13 | toc: 14 | - toc: reference 15 | - toc: release-notes 16 | subs: 17 | es: "Elasticsearch" 18 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | 4 | # GitHub actions 5 | - package-ecosystem: "github-actions" 6 | directories: 7 | - "/" 8 | - "/.github/workflows/*" 9 | schedule: 10 | interval: "weekly" 11 | day: "sunday" 12 | time: "22:00" 13 | groups: 14 | github-actions: 15 | patterns: 16 | - "*" 17 | -------------------------------------------------------------------------------- /test/Elastic.Apm.Tests.MockApmServer/MetricSampleDto.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable MemberCanBePrivate.Global 2 | // ReSharper disable ClassNeverInstantiated.Global 3 | // ReSharper disable UnusedAutoPropertyAccessor.Global 4 | 5 | 6 | namespace Elastic.Apm.Tests.MockApmServer 7 | { 8 | internal class MetricSampleDto 9 | { 10 | public double Value { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/azure/applications/Elastic.Apm.AzureFunctionApp.Core/Elastic.Apm.AzureFunctionApp.Core.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | false 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /test/iis/AspNetFullFrameworkSampleApp/Views/Account/ConfirmEmail.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewBag.Title = "Confirm Email"; 3 | } 4 | 5 |

@ViewBag.Title

6 |
7 |

8 | Thank you for confirming your email. Please @Html.ActionLink("Click here to Log in", "Login", "Account", routeValues: null, htmlAttributes: new { id = "loginLink" }) 9 |

10 |
11 | -------------------------------------------------------------------------------- /test/integrations/applications/SampleAspNetCoreApp/Views/Account/Login.cshtml: -------------------------------------------------------------------------------- 1 |
2 |
3 | 4 |
5 | 6 | 7 | 8 | 9 |
-------------------------------------------------------------------------------- /sample/ApiSamples/ApiSamples.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net8.0 6 | false 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /test/Elastic.Apm.Tests.MockApmServer/IDto.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | namespace Elastic.Apm.Tests.MockApmServer 6 | { 7 | public interface IDto 8 | { 9 | void AssertValid(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /.github/workflows/github-commands-comment.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: github-commands-comment 3 | 4 | on: 5 | pull_request_target: 6 | types: 7 | - opened 8 | 9 | permissions: 10 | contents: read 11 | 12 | jobs: 13 | comment: 14 | runs-on: ubuntu-latest 15 | permissions: 16 | pull-requests: write 17 | steps: 18 | - uses: elastic/oblt-actions/elastic/github-commands@v1 19 | -------------------------------------------------------------------------------- /test/Elastic.Apm.Tests.Utilities/ILineWriter.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | namespace Elastic.Apm.Tests.Utilities 6 | { 7 | public interface ILineWriter 8 | { 9 | void WriteLine(string line); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/Elastic.Apm/Helpers/AssertionLevel.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | namespace Elastic.Apm.Helpers 6 | { 7 | internal enum AssertionLevel 8 | { 9 | Disabled = 0, 10 | O_1 = 1, 11 | O_n = 2 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/integrations/Elastic.Apm.StaticImplicitInitialization.Tests/Elastic.Apm.StaticImplicitInitialization.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /test/iis/AspNetFullFrameworkSampleApp/Mvc/JsonBadRequestResult.cs: -------------------------------------------------------------------------------- 1 | using System.Web.Mvc; 2 | 3 | namespace AspNetFullFrameworkSampleApp.Mvc 4 | { 5 | public class JsonBadRequestResult : JsonResult 6 | { 7 | public override void ExecuteResult(ControllerContext context) 8 | { 9 | context.RequestContext.HttpContext.Response.StatusCode = 400; 10 | base.ExecuteResult(context); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/integrations/applications/SampleAspNetCoreApp/Views/Home/CookiePage.cshtml: -------------------------------------------------------------------------------- 1 |
2 | -------------------------------------------------------------------------------- /test/integrations/applications/SampleConsoleNetCoreApp/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Debug", 5 | "System": "Information", 6 | "Microsoft": "Information" 7 | } 8 | }, 9 | 10 | "ElasticApm": { 11 | "ServerUrls": "http://localhost:8200" 12 | }, 13 | 14 | "Console": { 15 | "IncludeScopes": true // Required to use Scopes. 16 | } 17 | } -------------------------------------------------------------------------------- /test/integrations/applications/WebApiSample/WebApiSample.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | false 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /test/Elastic.Apm.Tests.MockApmServer/ITimedDto.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | namespace Elastic.Apm.Tests.MockApmServer 6 | { 7 | public interface ITimedDto : ITimestampedDto 8 | { 9 | double Duration { get; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/Elastic.Apm.Tests.MockApmServer/ITimestampedDto.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | namespace Elastic.Apm.Tests.MockApmServer 6 | { 7 | public interface ITimestampedDto : IDto 8 | { 9 | long Timestamp { get; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/Elastic.Apm/Config/IConfigurationSnapshotProvider.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | namespace Elastic.Apm.Config 6 | { 7 | internal interface IConfigurationSnapshotProvider 8 | { 9 | IConfiguration CurrentSnapshot { get; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/integrations/applications/SampleAspNetCoreApp/Views/Home/SimplePage.cshtml: -------------------------------------------------------------------------------- 1 |
2 | -------------------------------------------------------------------------------- /sample/WorkerServiceSample/Program.cs: -------------------------------------------------------------------------------- 1 | using Elastic.Apm.DiagnosticSource; 2 | using WorkerServiceSample; 3 | 4 | var builder = Host.CreateApplicationBuilder(args); 5 | 6 | builder.Services.AddHttpClient(); 7 | builder.Services.AddElasticApm(new HttpDiagnosticsSubscriber()); // register Elastic APM before registering other IHostedServices 8 | builder.Services.AddHostedService(); 9 | 10 | var host = builder.Build(); 11 | host.Run(); 12 | -------------------------------------------------------------------------------- /test/iis/AspNetFullFrameworkSampleApp/Views/Account/ResetPasswordConfirmation.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewBag.Title = "Reset password confirmation"; 3 | } 4 | 5 |
6 |

@ViewBag.Title

7 |
8 |
9 |

10 | Your password has been reset. Please @Html.ActionLink("Click here to log in", "Login", "Account", routeValues: null, htmlAttributes: new { id = "loginLink" }) 11 |

12 |
13 | -------------------------------------------------------------------------------- /test/integrations/Elastic.Apm.AspNetCore.Tests/TestConfigs/appsettings_invalid.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Warning" 5 | } 6 | }, 7 | "AllowedHosts": "*", 8 | "ElasticApm": 9 | { 10 | "LogLevel": "DbeugMisspelled", 11 | "ServerUrls": "InvalidUrl", 12 | "CaptureHeaders": "fallsee", 13 | "TransactionSampleRate": "not a valid floating point number" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/Elastic.Apm/BackendComm/CentralConfig/ICentralConfigurationFetcher.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | using System; 6 | 7 | namespace Elastic.Apm.BackendComm.CentralConfig 8 | { 9 | internal interface ICentralConfigurationFetcher : IDisposable { } 10 | } 11 | -------------------------------------------------------------------------------- /test/instrumentations/grpc/GrpcServiceSample/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "AllowedHosts": "*", 10 | "Kestrel": { 11 | "EndpointDefaults": { 12 | "Protocols": "Http2" 13 | } 14 | }, 15 | "ElasticApm": { 16 | "CloudProvider": "none" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /.github/workflows/docs-build.yml: -------------------------------------------------------------------------------- 1 | name: docs-build 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | pull_request_target: ~ 8 | merge_group: ~ 9 | 10 | jobs: 11 | docs-preview: 12 | uses: elastic/docs-builder/.github/workflows/preview-build.yml@main 13 | with: 14 | path-pattern: docs/** 15 | permissions: 16 | deployments: write 17 | id-token: write 18 | contents: read 19 | pull-requests: write 20 | -------------------------------------------------------------------------------- /src/Elastic.Apm/Api/Container.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | using Elastic.Apm.Api.Constraints; 6 | 7 | namespace Elastic.Apm.Api 8 | { 9 | public class Container 10 | { 11 | [Required] 12 | [MaxLength] 13 | public string Id { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/Elastic.Apm/Config/IConfigurationStore.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | namespace Elastic.Apm.Config 6 | { 7 | internal interface IConfigurationStore : IConfigurationSnapshotProvider 8 | { 9 | new IConfiguration CurrentSnapshot { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/iis/Elastic.Apm.FullFramework.Tests/Elastic.Apm.FullFramework.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net462;net8.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /test/integrations/applications/SampleAspNetCoreApp/Data/SampleData.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | namespace SampleAspNetCoreApp.Data 6 | { 7 | public class SampleData 8 | { 9 | public int Id { get; set; } 10 | public string Name { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /sample/HttpListenerSample/HttpListenerSample.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net8.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /test/integrations/Elastic.Apm.Extensions.Tests.Shared/Elastic.Apm.Extensions.Tests.Shared.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /test/startuphook/Elastic.Apm.StartupHook.Sample/Program.cs: -------------------------------------------------------------------------------- 1 | 2 | using Microsoft.AspNetCore; 3 | using Microsoft.AspNetCore.Hosting; 4 | 5 | namespace Elastic.Apm.StartupHook.Sample 6 | { 7 | public class Program 8 | { 9 | public static void Main(string[] args) => CreateHostBuilder(args).Build().Run(); 10 | 11 | public static IWebHostBuilder CreateHostBuilder(string[] args) => 12 | WebHost.CreateDefaultBuilder(args).UseStartup(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/Elastic.Apm.Tests.Utilities/FluentAssertionsUtils.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | using System; 6 | 7 | namespace Elastic.Apm.Tests.Utilities 8 | { 9 | public static class FluentAssertionsUtils 10 | { 11 | public static Action AsAction(Action action) => action; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/opentelemetry/OpenTelemetrySample/OpenTelemetrySample.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net8.0 6 | Linux 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /test/Elastic.Apm.Tests.Utilities/FakeMetricsCollector.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | using Elastic.Apm.Metrics; 6 | 7 | namespace Elastic.Apm.Tests.Utilities 8 | { 9 | public class FakeMetricsCollector : IMetricsCollector 10 | { 11 | public void StartCollecting() { } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/integrations/applications/WebApiSample/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Warning", 5 | "Elastic.Apm": "Error" 6 | } 7 | }, 8 | "AllowedHosts": "*", 9 | "ElasticApm": { 10 | "ServerUrls": "http://localhost:8200", 11 | "CaptureBody": "all", 12 | "CaptureBodyContentTypes": "application/x-www-form-urlencoded*, text/*, application/json*, application/xml*", 13 | "CloudProvider": "none" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/Elastic.Apm/Helpers/AssertionFailedException.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | using System; 6 | 7 | namespace Elastic.Apm.Helpers 8 | { 9 | internal class AssertionFailedException : Exception 10 | { 11 | internal AssertionFailedException(string message) : base(message) { } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/integrations/applications/SampleAspNetCoreApp/Views/Account/Register.cshtml: -------------------------------------------------------------------------------- 1 |
2 |
3 | 4 |
5 | 6 | 7 | 8 | 9 |
10 | 11 |
12 | 13 | @if (ViewData["msg"] != null) 14 | { 15 | @ViewData["msg"] 16 | } -------------------------------------------------------------------------------- /test/profiler/applications/MySqlDataSample/MySqlDataSample.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net462;net8.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /test/profiler/applications/RabbitMqSample/RabbitMqSample.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net8.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /test/profiler/applications/SatelliteAssemblySample/SatelliteAssemblySample.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net8.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /test/instrumentations/Elastic.Apm.Docker.Tests/Elastic.Apm.Docker.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /test/profiler/applications/SatelliteAssemblySample/Program.cs: -------------------------------------------------------------------------------- 1 | using System.Globalization; 2 | using Microsoft.FSharp.Collections; 3 | 4 | var germanCulture = new CultureInfo("de"); 5 | CultureInfo.CurrentCulture = germanCulture; 6 | CultureInfo.CurrentUICulture = germanCulture; 7 | 8 | // Throw a localized ArgumentException 9 | try 10 | { 11 | SeqModule.Head(SeqModule.Empty()); 12 | } 13 | catch (ArgumentException ex) 14 | { 15 | Console.WriteLine($"Handled: {ex.Message}"); 16 | } 17 | -------------------------------------------------------------------------------- /src/azure/Elastic.Apm.Azure.ServiceBus/ServiceBus.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under 2 | // one or more agreements. 3 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 4 | // See the LICENSE file in the project root for more information 5 | 6 | namespace Elastic.Apm.Azure.ServiceBus 7 | { 8 | internal static class ServiceBus 9 | { 10 | public const string SegmentName = "AzureServiceBus"; 11 | public const string SubType = "azureservicebus"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/integrations/Elastic.Apm.AspNetFullFramework/OpenIdClaimTypes.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under 2 | // one or more agreements. 3 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 4 | // See the LICENSE file in the project root for more information 5 | 6 | namespace Elastic.Apm.AspNetFullFramework 7 | { 8 | internal static class OpenIdClaimTypes 9 | { 10 | internal const string Email = "email"; 11 | internal const string UserId = "sub"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/Elastic.Apm/Libraries/Ben.Demystifier/Enumerable/IEnumerableIList.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Ben A Adams. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 3 | 4 | using System.Collections.Generic; 5 | 6 | #nullable enable 7 | namespace Elastic.Apm.Libraries.Ben.Demystifier.Enumerable 8 | { 9 | internal interface IEnumerableIList : IEnumerable 10 | { 11 | new EnumeratorIList GetEnumerator(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/integrations/Elastic.Apm.AspNetCore/Consts.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | namespace Elastic.Apm.AspNetCore; 6 | 7 | internal static class Consts 8 | { 9 | internal static class OpenIdClaimTypes 10 | { 11 | internal const string Email = "email"; 12 | internal const string UserId = "sub"; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/profiler/Elastic.Apm.Profiler.IntegrationsGenerator/MethodReplacement.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under 2 | // one or more agreements. 3 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 4 | // See the LICENSE file in the project root for more information 5 | 6 | namespace Elastic.Apm.Profiler.IntegrationsGenerator 7 | { 8 | public class MethodReplacement 9 | { 10 | public Target Target { get; set; } 11 | public Wrapper Wrapper { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/instrumentations/Elastic.Apm.SqlClient.Tests/SqlServerCollection.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under 2 | // one or more agreements. 3 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 4 | // See the LICENSE file in the project root for more information 5 | 6 | using Xunit; 7 | 8 | namespace Elastic.Apm.SqlClient.Tests 9 | { 10 | [CollectionDefinition("SqlServer")] 11 | public class SqlServerCollection : ICollectionFixture 12 | { 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/profiler/applications/Elastic.Apm.AdoNet/Elastic.Apm.AdoNet.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net462;net8.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /sample/WebApiExample/Program.cs: -------------------------------------------------------------------------------- 1 | var builder = WebApplication.CreateBuilder(args); 2 | 3 | builder.Services.AddAllElasticApm(); 4 | builder.Services.AddControllers(); 5 | builder.Services.AddEndpointsApiExplorer(); 6 | builder.Services.AddSwaggerGen(); 7 | 8 | var app = builder.Build(); 9 | 10 | if (app.Environment.IsDevelopment()) 11 | { 12 | app.UseSwagger(); 13 | app.UseSwaggerUI(); 14 | } 15 | 16 | app.UseHttpsRedirection(); 17 | app.UseAuthorization(); 18 | app.MapControllers(); 19 | 20 | app.Run(); 21 | -------------------------------------------------------------------------------- /src/Elastic.Apm/Libraries/Newtonsoft.Json/Linq/JsonPath/RootFilter.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | #nullable enable 4 | namespace Elastic.Apm.Libraries.Newtonsoft.Json.Linq.JsonPath 5 | { 6 | internal class RootFilter : PathFilter 7 | { 8 | public static readonly RootFilter Instance = new(); 9 | 10 | private RootFilter() { } 11 | 12 | public override IEnumerable ExecuteFilter(JToken root, IEnumerable current, JsonSelectSettings? settings) => new[] { root }; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/profiler/elastic_apm_profiler/src/cil/mod.rs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under 2 | // one or more agreements. 3 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 4 | // See the LICENSE file in the project root for more information 5 | 6 | mod cor; 7 | mod helpers; 8 | mod instruction; 9 | mod method; 10 | mod opcode; 11 | mod section; 12 | 13 | pub use self::{cor::*, helpers::*, instruction::*, method::*, opcode::*, section::*}; 14 | 15 | pub const MAX_LENGTH: u32 = 1024; 16 | -------------------------------------------------------------------------------- /test/integrations/applications/SampleAspNetCoreApp/Models/ErrorViewModel.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | namespace SampleAspNetCoreApp.Models 6 | { 7 | public class ErrorViewModel 8 | { 9 | public string RequestId { get; set; } 10 | 11 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/Elastic.Apm.Tests.Utilities/NoopCentralConfigurationFetcher.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | using Elastic.Apm.BackendComm.CentralConfig; 6 | 7 | namespace Elastic.Apm.Tests.Utilities 8 | { 9 | public class NoopCentralConfigurationFetcher : ICentralConfigurationFetcher 10 | { 11 | public void Dispose() { } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/profiler/applications/OracleManagedDataAccessSample/OracleManagedDataAccessSample.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net462 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /.github/workflows/test-reporter.yml: -------------------------------------------------------------------------------- 1 | on: 2 | workflow_run: 3 | workflows: 4 | - test-windows 5 | types: 6 | - completed 7 | 8 | permissions: 9 | contents: read 10 | actions: read 11 | checks: write 12 | 13 | jobs: 14 | report: 15 | runs-on: ubuntu-latest 16 | steps: 17 | - uses: elastic/oblt-actions/test-report@v1 18 | with: 19 | artifact: /test-results(.*)/ 20 | name: 'Test Repot $1' 21 | path: "**/*.xml" 22 | reporter: java-junit 23 | -------------------------------------------------------------------------------- /src/profiler/Elastic.Apm.Profiler.IntegrationsGenerator/Wrapper.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under 2 | // one or more agreements. 3 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 4 | // See the LICENSE file in the project root for more information 5 | 6 | namespace Elastic.Apm.Profiler.IntegrationsGenerator 7 | { 8 | public class Wrapper 9 | { 10 | public string Assembly { get; set; } 11 | public string Type { get; set; } 12 | public string Action { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/iis/AspNetFullFrameworkSampleApp/Consts.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | namespace AspNetFullFrameworkSampleApp 6 | { 7 | public class Consts 8 | { 9 | public const string ElasticApmServerUrlsResponseHeaderName = "Elastic-APM-Server-URLs"; 10 | public const string ProcessIdResponseHeaderName = "Process-ID"; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/instrumentations/Elastic.Apm.GrpcClient/Elastic.Apm.GrpcClient.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | true 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /test/Elastic.Apm.Tests.Utilities/Azure/AzureResourceException.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under 2 | // one or more agreements. 3 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 4 | // See the LICENSE file in the project root for more information 5 | 6 | using System; 7 | 8 | namespace Elastic.Apm.Tests.Utilities.Azure 9 | { 10 | public class AzureResourceException : Exception 11 | { 12 | public AzureResourceException(string message) : base(message) 13 | { 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /test/iis/AspNetFullFrameworkSampleApp/Models/CreateSampleDataViewModel.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under 2 | // one or more agreements. 3 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 4 | // See the LICENSE file in the project root for more information 5 | 6 | using System.ComponentModel.DataAnnotations; 7 | 8 | namespace AspNetFullFrameworkSampleApp.Models 9 | { 10 | public class CreateSampleDataViewModel 11 | { 12 | [Required] 13 | public string Name { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/integrations/Elastic.Apm.StaticExplicitInitialization.Tests/Elastic.Apm.StaticExplicitInitialization.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /sample/WebApiExample/Controllers/ErrorController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | 3 | namespace WebApiExample.Controllers; 4 | 5 | [ApiController] 6 | [Route("[controller]")] 7 | public class ErrorController : ControllerBase 8 | { 9 | private readonly ILogger _logger; 10 | 11 | public ErrorController(ILogger logger) => _logger = logger; 12 | 13 | [HttpGet(Name = "GetError")] 14 | public IEnumerable Get() => 15 | throw new Exception("This exception triggers a 500"); 16 | } 17 | -------------------------------------------------------------------------------- /src/Elastic.Apm/ServerInfo/ApmServerInfo.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under 2 | // one or more agreements. 3 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 4 | // See the LICENSE file in the project root for more information 5 | 6 | namespace Elastic.Apm.ServerInfo 7 | { 8 | /// 9 | /// A "real" implementation. 10 | /// 11 | internal class ApmServerInfo : IApmServerInfo 12 | { 13 | public ElasticVersion Version { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/iis/AspNetFullFrameworkSampleApp/Views/Home/Contact.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewBag.Title = "Contact"; 3 | } 4 |

@ViewBag.Title.

5 |

@ViewBag.Message

6 | 7 |
8 | One Microsoft Way
9 | Redmond, WA 98052-6399
10 | P: 11 | 425.555.0100 12 |
13 | 14 |
15 | Support: Support@example.com
16 | Marketing: Marketing@example.com 17 |
-------------------------------------------------------------------------------- /src/profiler/elastic_apm_profiler/src/error.rs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under 2 | // one or more agreements. 3 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 4 | // See the LICENSE file in the project root for more information 5 | 6 | #[derive(Debug)] 7 | #[non_exhaustive] 8 | pub enum Error { 9 | InvalidMethodHeader, 10 | InvalidSectionHeader, 11 | InvalidCil, 12 | InvalidCilOpcode, 13 | CodeSize, 14 | StackSize, 15 | InvalidVersion, 16 | InvalidAssemblyReference, 17 | } 18 | -------------------------------------------------------------------------------- /test/iis/AspNetFullFrameworkSampleApp/App_Start/FilterConfig.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | using System.Web.Mvc; 6 | 7 | namespace AspNetFullFrameworkSampleApp 8 | { 9 | public class FilterConfig 10 | { 11 | public static void RegisterGlobalFilters(GlobalFilterCollection filters) => 12 | filters.Add(new HandleErrorAttribute()); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/profiler/applications/OracleManagedDataAccessCoreSample/OracleManagedDataAccessCoreSample.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net8.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/Elastic.Apm/Helpers/LogLevelUtils.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | using Elastic.Apm.Logging; 6 | 7 | namespace Elastic.Apm.Helpers 8 | { 9 | internal static class LogLevelUtils 10 | { 11 | internal static LogLevel GetFinest(LogLevel logLevel1, LogLevel logLevel2) => 12 | logLevel1.CompareTo(logLevel2) <= 0 ? logLevel1 : logLevel2; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/iis/AspNetFullFrameworkSampleApp/Models/ApplicationUser.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under 2 | // one or more agreements. 3 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 4 | // See the LICENSE file in the project root for more information 5 | 6 | using Microsoft.AspNet.Identity.EntityFramework; 7 | 8 | namespace AspNetFullFrameworkSampleApp.Models 9 | { 10 | /// 11 | /// A user of this application 12 | /// 13 | public class ApplicationUser : IdentityUser 14 | { 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /test/azure/applications/Elastic.AzureFunctionApp.Isolated/Program.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | using Elastic.Apm.Azure.Functions; 6 | using Microsoft.Extensions.Hosting; 7 | 8 | var host = new HostBuilder() 9 | .ConfigureFunctionsWebApplication(builder => 10 | { 11 | builder.UseMiddleware(); 12 | }) 13 | .Build(); 14 | 15 | host.Run(); 16 | -------------------------------------------------------------------------------- /test/opentelemetry/OpenTelemetrySample/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Elastic.Apm; 3 | 4 | namespace OpenTelemetrySample 5 | { 6 | internal class Program 7 | { 8 | // ReSharper disable once ArrangeTypeMemberModifiers 9 | private static void Main() 10 | { 11 | Agent.Setup(new AgentComponents()); 12 | OTSamples.Sample1(); 13 | OTSamples.Sample2(Agent.Tracer); 14 | OTSamples.Sample3(Agent.Tracer); 15 | OTSamples.Sample4(Agent.Tracer); 16 | OTSamples.SpanKindSample(); 17 | 18 | Console.ReadKey(); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/Elastic.Apm/Api/Constraints/RequiredAttribute.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under 2 | // one or more agreements. 3 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 4 | // See the LICENSE file in the project root for more information 5 | 6 | using System; 7 | 8 | namespace Elastic.Apm.Api.Constraints 9 | { 10 | /// 11 | /// Specifies that a data field value is required. 12 | /// 13 | [AttributeUsage(AttributeTargets.Property)] 14 | public sealed class RequiredAttribute : Attribute { } 15 | } 16 | -------------------------------------------------------------------------------- /test/Elastic.Apm.Tests.Utilities/ApmAgentTestExtensions.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under 2 | // one or more agreements. 3 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 4 | // See the LICENSE file in the project root for more information 5 | 6 | using System; 7 | using System.Collections.Generic; 8 | 9 | namespace Elastic.Apm.Tests.Utilities; 10 | 11 | public static class ApmAgentTestExtensions 12 | { 13 | public static HashSet SubscribedListeners(this IApmAgent agent) => agent.SubscribedListeners; 14 | } 15 | -------------------------------------------------------------------------------- /src/profiler/Elastic.Apm.Profiler.IntegrationsGenerator/Integration.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under 2 | // one or more agreements. 3 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 4 | // See the LICENSE file in the project root for more information 5 | 6 | using System.Collections.Generic; 7 | 8 | namespace Elastic.Apm.Profiler.IntegrationsGenerator 9 | { 10 | public class Integration 11 | { 12 | public string Name { get; set; } 13 | 14 | public IEnumerable MethodReplacements { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /test/integrations/applications/SampleAspNetCoreApp/Areas/MyArea/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under 2 | // one or more agreements. 3 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 4 | // See the LICENSE file in the project root for more information 5 | 6 | using Microsoft.AspNetCore.Mvc; 7 | 8 | namespace SampleAspNetCoreApp.Areas.MyArea.Controllers 9 | { 10 | [Area("MyArea")] 11 | public class HomeController : Controller 12 | { 13 | // GET 14 | public IActionResult Index() => View(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /test/Elastic.Apm.Tests.MockApmServer/SpanLinkDto.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under 2 | // one or more agreements. 3 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 4 | // See the LICENSE file in the project root for more information 5 | 6 | using Elastic.Apm.Libraries.Newtonsoft.Json; 7 | 8 | namespace Elastic.Apm.Tests.MockApmServer; 9 | 10 | internal class SpanLinkDto 11 | { 12 | [JsonProperty("span_id")] 13 | public string SpanId { get; set; } 14 | 15 | [JsonProperty("trace_id")] 16 | public string TraceId { get; set; } 17 | } 18 | -------------------------------------------------------------------------------- /test/iis/AspNetFullFrameworkSampleApp/Content/Site.css: -------------------------------------------------------------------------------- 1 | /* Set padding to keep content from hitting the edges */ 2 | .body-content { 3 | padding-left: 15px; 4 | padding-right: 15px; 5 | } 6 | 7 | /* Override the default bootstrap behavior where horizontal description lists 8 | will truncate terms that are too long to fit in the left column 9 | */ 10 | .dl-horizontal dt { 11 | white-space: normal; 12 | } 13 | 14 | /* Set width on the form input elements since they're 100% wide by default */ 15 | input, 16 | select, 17 | textarea { 18 | max-width: 280px; 19 | } 20 | -------------------------------------------------------------------------------- /test/iis/AspNetFullFrameworkSampleApp/Models/ForgotPasswordViewModel.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under 2 | // one or more agreements. 3 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 4 | // See the LICENSE file in the project root for more information 5 | 6 | using System.ComponentModel.DataAnnotations; 7 | 8 | namespace AspNetFullFrameworkSampleApp.Models 9 | { 10 | public class ForgotPasswordViewModel 11 | { 12 | [Required] 13 | [EmailAddress] 14 | [Display(Name = "Email")] 15 | public string Email { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /test/opentelemetry/Elastic.Apm.OpenTelemetry.Tests/Elastic.Apm.OpenTelemetry.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/Elastic.Apm/Config/IConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under 2 | // one or more agreements. 3 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 4 | // See the LICENSE file in the project root for more information 5 | 6 | namespace Elastic.Apm.Config 7 | { 8 | /// 9 | /// A snapshot of agent configuration containing values 10 | /// initial configuration combined with dynamic values from central configuration, if enabled. 11 | /// 12 | public interface IConfiguration : IConfigurationReader 13 | { 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/Elastic.Apm.Tests.Utilities/XUnit/DisabledOnWindowsTheory.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under 2 | // one or more agreements. 3 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 4 | // See the LICENSE file in the project root for more information 5 | 6 | using Xunit; 7 | 8 | namespace Elastic.Apm.Tests.Utilities.XUnit; 9 | 10 | public sealed class DisabledOnWindowsTheory : TheoryAttribute 11 | { 12 | public DisabledOnWindowsTheory() 13 | { 14 | if (TestEnvironment.IsWindows) 15 | Skip = "This test is disabled on Windows."; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /test/Elastic.Apm.Tests/HelpersTests/DbgUtilsTests.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | using Elastic.Apm.Helpers; 6 | using FluentAssertions; 7 | using Xunit; 8 | 9 | namespace Elastic.Apm.Tests.HelpersTests 10 | { 11 | public class DbgUtilsTests 12 | { 13 | [Fact] 14 | public void CurrentMethodName_test() => DbgUtils.CurrentMethodName().Should().Be(nameof(CurrentMethodName_test)); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /test/integrations/applications/SampleAspNetCoreApp/Areas/MyOtherArea/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under 2 | // one or more agreements. 3 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 4 | // See the LICENSE file in the project root for more information 5 | 6 | using Microsoft.AspNetCore.Mvc; 7 | 8 | namespace SampleAspNetCoreApp.Areas.MyOtherArea.Controllers 9 | { 10 | [Area("MyOtherArea")] 11 | public class HomeController : Controller 12 | { 13 | // GET 14 | public IActionResult Index() => View(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /test/startuphook/Elastic.Apm.StartupHook.Tests/Elastic.Apm.StartupHook.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/profiler/elastic_apm_profiler/src/interfaces/imap_token.rs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under 2 | // one or more agreements. 3 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 4 | // See the LICENSE file in the project root for more information 5 | 6 | use crate::ffi::mdToken; 7 | use com::{interfaces::iunknown::IUnknown, sys::HRESULT}; 8 | 9 | interfaces! { 10 | #[uuid("06A3EA8B-0225-11d1-BF72-00C04FC31E12")] 11 | pub unsafe interface IMapToken: IUnknown { 12 | fn Map(&self, tkImp: mdToken, tkEmit: mdToken) -> HRESULT; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/Elastic.Apm.Tests.Utilities/NoopCurrentExecutionSegmentsContainer.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | using Elastic.Apm.Api; 6 | 7 | namespace Elastic.Apm.Tests.Utilities 8 | { 9 | internal class NoopCurrentExecutionSegmentsContainer : ICurrentExecutionSegmentsContainer 10 | { 11 | public ISpan CurrentSpan { get; set; } 12 | public ITransaction CurrentTransaction { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/iis/AspNetFullFrameworkSampleApp/Areas/MyArea/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under 2 | // one or more agreements. 3 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 4 | // See the LICENSE file in the project root for more information 5 | 6 | using System.Web.Mvc; 7 | 8 | namespace AspNetFullFrameworkSampleApp.Areas.MyArea.Controllers 9 | { 10 | public class HomeController : Controller 11 | { 12 | internal const string HomePageRelativePath = "MyArea/Home"; 13 | 14 | public ActionResult Index() => View(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /test/azure/applications/Elastic.AzureFunctionApp.Isolated/local.settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "IsEncrypted": false, 3 | "Values": { 4 | "AzureWebJobsStorage": "UseDevelopmentStorage=true", 5 | "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated", 6 | "FUNCTIONS_EXTENSION_VERSION": "4", 7 | "WEBSITE_OWNER_NAME": "abcd1234-abcd-acdc-1234-112233445566+testfaas_group-CentralUSwebspace-Linux", 8 | "WEBSITE_SITE_NAME": "testfaas", 9 | // Include this breaks on the latest version of func - Excluding it for now. 10 | //"WEBSITE_INSTANCE_ID": "20367ea8-70b9-41b4-a552-b2a826b3aa0b" 11 | } 12 | } -------------------------------------------------------------------------------- /test/iis/AspNetFullFrameworkSampleApp/Views/Database/Index.cshtml: -------------------------------------------------------------------------------- 1 | @model IEnumerable 2 | 3 | @if (!Model.Any()) 4 | { 5 |

No samples in the database.

6 | } 7 | else 8 | { 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | @foreach (var sample in Model) 18 | { 19 | 20 | 21 | 22 | 23 | } 24 | 25 |
IdName
@sample.Id@sample.Name
26 | } -------------------------------------------------------------------------------- /test/instrumentations/grpc/GrpcServiceSample/GrpcServiceSample.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/Elastic.Apm/Api/Kubernetes/Node.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | using Elastic.Apm.Api.Constraints; 6 | using Elastic.Apm.Helpers; 7 | 8 | namespace Elastic.Apm.Api.Kubernetes 9 | { 10 | public class Node 11 | { 12 | [MaxLength] 13 | public string Name { get; set; } 14 | 15 | public override string ToString() => new ToStringBuilder(nameof(Node)) { { nameof(Name), Name } }.ToString(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/Elastic.Apm/Helpers/CollectionExtensions.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | using System.Collections.Generic; 6 | using System.Runtime.CompilerServices; 7 | 8 | namespace Elastic.Apm.Helpers 9 | { 10 | internal static class CollectionExtensions 11 | { 12 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 13 | internal static bool IsEmpty(this List thisObj) => thisObj.Count == 0; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/Elastic.Apm.Specification/Elastic.Apm.Specification.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0;net462 5 | false 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/Elastic.Apm/BackendComm/CentralConfig/ICentralConfigurationResponseParser.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | using System.Net.Http; 6 | 7 | namespace Elastic.Apm.BackendComm.CentralConfig 8 | { 9 | internal interface ICentralConfigurationResponseParser 10 | { 11 | (CentralConfiguration, CentralConfigurationFetcher.WaitInfoS) ParseHttpResponse(HttpResponseMessage httpResponse, string httpResponseBody); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/Elastic.Apm.Tests.Utilities/NoopLogger.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | using System; 6 | using Elastic.Apm.Logging; 7 | 8 | namespace Elastic.Apm.Tests.Utilities 9 | { 10 | internal class NoopLogger : IApmLogger 11 | { 12 | public bool IsEnabled(LogLevel level) => false; 13 | 14 | public void Log(LogLevel level, TState state, Exception e, Func formatter) { } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /test/profiler/applications/NpgsqlSample/NpgsqlSample.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5.0.18 5 | Exe 6 | net462;net8.0 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /sample/Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $(SolutionRoot)/build/sampleapps.snk 5 | false 6 | 8 | false 9 | 10 | -------------------------------------------------------------------------------- /sample/StackExchangeRedisSample/StackExchangeRedisSample.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net8.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/Elastic.Apm/Libraries/Newtonsoft.Json/Linq/MergeNullValueHandling.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | #nullable enable 4 | namespace Elastic.Apm.Libraries.Newtonsoft.Json.Linq 5 | { 6 | /// 7 | /// Specifies how null value properties are merged. 8 | /// 9 | [Flags] 10 | internal enum MergeNullValueHandling 11 | { 12 | /// 13 | /// The content's null value properties will be ignored during merging. 14 | /// 15 | Ignore = 0, 16 | 17 | /// 18 | /// The content's null value properties will be merged. 19 | /// 20 | Merge = 1 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /test/Elastic.Apm.Tests.MockApmServer/CompositeDto.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | using Elastic.Apm.Libraries.Newtonsoft.Json; 6 | 7 | namespace Elastic.Apm.Tests.MockApmServer 8 | { 9 | public class CompositeDto 10 | { 11 | [JsonProperty("compression_strategy")] 12 | public string CompressionStrategy { get; set; } 13 | 14 | public int Count { get; set; } 15 | 16 | public double Sum { get; set; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /test/iis/Elastic.Apm.AspNetFullFramework.Tests/AspNetFullFrameworkFact.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | using System; 6 | using Xunit; 7 | 8 | namespace Elastic.Apm.AspNetFullFramework.Tests 9 | { 10 | [AttributeUsage(AttributeTargets.Method)] 11 | public sealed class AspNetFullFrameworkFact : FactAttribute 12 | { 13 | public AspNetFullFrameworkFact() => Skip = TestsEnabledDetector.ReasonWhyTestsAreSkipped; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/integrations/applications/SampleAspNetCoreApp/wwwroot/lib/jquery-validation-unobtrusive/.bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery-validation-unobtrusive", 3 | "homepage": "https://github.com/aspnet/jquery-validation-unobtrusive", 4 | "version": "3.2.9", 5 | "_release": "3.2.9", 6 | "_resolution": { 7 | "type": "version", 8 | "tag": "v3.2.9", 9 | "commit": "a91f5401898e125f10771c5f5f0909d8c4c82396" 10 | }, 11 | "_source": "https://github.com/aspnet/jquery-validation-unobtrusive.git", 12 | "_target": "^3.2.9", 13 | "_originalSource": "jquery-validation-unobtrusive", 14 | "_direct": true 15 | } -------------------------------------------------------------------------------- /src/instrumentations/Elastic.Apm.MongoDb/EventPayload.cs: -------------------------------------------------------------------------------- 1 | // Based on the elastic-apm-mongo project by Vadim Hatsura (@vhatsura) 2 | // https://github.com/vhatsura/elastic-apm-mongo 3 | // Licensed to Elasticsearch B.V under the Apache 2.0 License. 4 | // Elasticsearch B.V licenses this file, including any modifications, to you under the Apache 2.0 License. 5 | // See the LICENSE file in the project root for more information. 6 | 7 | namespace Elastic.Apm.MongoDb 8 | { 9 | internal class EventPayload 10 | { 11 | public EventPayload(T @event) => Event = @event; 12 | 13 | public T Event { get; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/instrumentations/grpc/GrpcServiceSample/Protos/greet.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | option csharp_namespace = "GrpcServiceSample"; 4 | 5 | package greet; 6 | 7 | // The greeting service definition. 8 | service Greeter { 9 | // Sends a greeting 10 | rpc SayHello (HelloRequest) returns (HelloReply); 11 | rpc ThrowAnException (HelloRequest) returns (HelloReply); 12 | } 13 | 14 | // The request message containing the user's name. 15 | message HelloRequest { 16 | string name = 1; 17 | } 18 | 19 | // The response message containing the greetings. 20 | message HelloReply { 21 | string message = 1; 22 | } 23 | -------------------------------------------------------------------------------- /src/Elastic.Apm/Metrics/IMetricsCollector.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | namespace Elastic.Apm.Metrics 6 | { 7 | /// 8 | /// Defines how the agent collects metrics. 9 | /// 10 | internal interface IMetricsCollector 11 | { 12 | /// 13 | /// After calling this method, the starts collecting metrics 14 | /// 15 | void StartCollecting(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /test/iis/Elastic.Apm.AspNetFullFramework.Tests/AspNetFullFrameworkTheory.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | using System; 6 | using Xunit; 7 | 8 | namespace Elastic.Apm.AspNetFullFramework.Tests 9 | { 10 | [AttributeUsage(AttributeTargets.Method)] 11 | public sealed class AspNetFullFrameworkTheory : TheoryAttribute 12 | { 13 | public AspNetFullFrameworkTheory() => Skip = TestsEnabledDetector.ReasonWhyTestsAreSkipped; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/integrations/applications/SampleAspNetCoreApp/wwwroot/lib/bootstrap/dist/js/npm.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated via the `commonjs` Grunt task. You can require() this file in a CommonJS environment. 2 | require('../../js/transition.js'); 3 | require('../../js/alert.js'); 4 | require('../../js/button.js'); 5 | require('../../js/carousel.js'); 6 | require('../../js/collapse.js'); 7 | require('../../js/dropdown.js'); 8 | require('../../js/modal.js'); 9 | require('../../js/tooltip.js'); 10 | require('../../js/popover.js'); 11 | require('../../js/scrollspy.js'); 12 | require('../../js/tab.js'); 13 | require('../../js/affix.js'); -------------------------------------------------------------------------------- /test/azure/Elastic.Apm.Azure.CosmosDb.Tests/DocumentItem.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under 2 | // one or more agreements. 3 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 4 | // See the LICENSE file in the project root for more information 5 | 6 | using Newtonsoft.Json; 7 | 8 | namespace Elastic.Apm.Azure.CosmosDb.Tests 9 | { 10 | public class DocumentItem 11 | { 12 | [JsonProperty("id")] 13 | public string Id { get; set; } 14 | 15 | public string FirstName { get; set; } 16 | 17 | public string LastName { get; set; } 18 | 19 | public string PartitionKey => Id; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /test/profiler/applications/KafkaSample/KafkaSample.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 1.9.3 5 | Exe 6 | net8.0 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /sample/WebApiExample/WebApiExample.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/Elastic.Apm/Libraries/Newtonsoft.Json/Linq/MergeArrayHandling.cs: -------------------------------------------------------------------------------- 1 | #nullable enable 2 | namespace Elastic.Apm.Libraries.Newtonsoft.Json.Linq 3 | { 4 | /// 5 | /// Specifies how JSON arrays are merged together. 6 | /// 7 | internal enum MergeArrayHandling 8 | { 9 | /// Concatenate arrays. 10 | Concat = 0, 11 | 12 | /// Union arrays, skipping items that already exist. 13 | Union = 1, 14 | 15 | /// Replace all array items. 16 | Replace = 2, 17 | 18 | /// Merge array items together, matched by index. 19 | Merge = 3 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/profiler/Elastic.Apm.Profiler.IntegrationsGenerator/Elastic.Apm.Profiler.IntegrationsGenerator.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net8.0 6 | false 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /test/Elastic.Apm.Tests.Utilities/EnumerableTestExtensions.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | 9 | namespace Elastic.Apm.Tests.Utilities 10 | { 11 | internal static class EnumerableTestExtensions 12 | { 13 | internal static IEnumerable> ZipWithIndex(this IEnumerable source, int start = 0) => 14 | source.Select((t, i) => (i + start, t)); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/integrations/Elastic.Apm.AspNetFullFramework/AgentDependencies.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | using Elastic.Apm.Logging; 6 | 7 | namespace Elastic.Apm.AspNetFullFramework 8 | { 9 | /// 10 | /// Dependencies to initialize the APM agent with 11 | /// 12 | public static class AgentDependencies 13 | { 14 | /// 15 | /// The logger 16 | /// 17 | public static IApmLogger Logger { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/profiler/elastic_apm_profiler/elastic_apm_profiler.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | false 6 | false 7 | true 8 | false 9 | false 10 | $(ProjectDir) 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /test/azure/Elastic.Apm.Azure.Functions.Tests/Elastic.Apm.Azure.Functions.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | false 6 | Elastic.Apm.Azure.Functions.Tests 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/profiler/Elastic.Apm.Profiler.Managed/TracerExtensions.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under 2 | // one or more agreements. 3 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 4 | // See the LICENSE file in the project root for more information 5 | 6 | using Elastic.Apm.Api; 7 | 8 | namespace Elastic.Apm.Profiler.Managed 9 | { 10 | // TODO: this should be public in Elastic.Apm somewhere 11 | internal static class TracerExtensions 12 | { 13 | public static IExecutionSegment CurrentExecutionSegment(this ITracer tracer) => 14 | (IExecutionSegment)tracer.CurrentSpan ?? tracer.CurrentTransaction; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /test/profiler/applications/SqliteSample/SqliteSample.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8.0.2 5 | Exe 6 | net462;net8.0 7 | x64 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/Elastic.Apm/DiagnosticSource/IDiagnosticsSubscriber.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | using System; 6 | 7 | namespace Elastic.Apm.DiagnosticSource 8 | { 9 | public interface IDiagnosticsSubscriber 10 | { 11 | /// 12 | /// Subscribes to diagnostic listeners 13 | /// 14 | /// The agent components 15 | /// A disposable 16 | IDisposable Subscribe(IApmAgent components); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/Elastic.Apm/Libraries/Newtonsoft.Json/Serialization/DefaultNamingStrategy.cs: -------------------------------------------------------------------------------- 1 | #nullable enable 2 | namespace Elastic.Apm.Libraries.Newtonsoft.Json.Serialization 3 | { 4 | /// 5 | /// The default naming strategy. Property names and dictionary keys are unchanged. 6 | /// 7 | internal class DefaultNamingStrategy : NamingStrategy 8 | { 9 | /// 10 | /// Resolves the specified property name. 11 | /// 12 | /// The property name to resolve. 13 | /// The resolved property name. 14 | protected override string ResolvePropertyName(string name) => name; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /test/Elastic.Apm.Tests.Utilities/ThreadSafeIntCounter.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | using System.Threading; 6 | 7 | namespace Elastic.Apm.Tests.Utilities 8 | { 9 | internal class ThreadSafeIntCounter 10 | { 11 | internal ThreadSafeIntCounter(int initialValue = 0) => _value = initialValue; 12 | 13 | private volatile int _value; 14 | 15 | internal int Value => _value; 16 | 17 | internal int Increment() => Interlocked.Increment(ref _value); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /test/Elastic.Apm.Tests/Utilities/AgentFeaturesProviderScope.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under 2 | // one or more agreements. 3 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 4 | // See the LICENSE file in the project root for more information 5 | 6 | using System; 7 | using Elastic.Apm.Features; 8 | 9 | namespace Elastic.Apm.Tests.Utilities; 10 | 11 | internal class AgentFeaturesProviderScope : IDisposable 12 | { 13 | internal AgentFeaturesProviderScope(AgentFeatures agentFeatures = null) => AgentFeaturesProvider.Set(agentFeatures); 14 | public void Dispose() => AgentFeaturesProvider.Set(null); 15 | } 16 | 17 | 18 | -------------------------------------------------------------------------------- /sample/WorkerServiceSample/WorkerServiceSample.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | dotnet-WorkerServiceSample-4a2affa2-a620-462a-87a0-e6e0f3f309fe 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /test/azure/applications/Elastic.AzureFunctionApp.InProcess/local.settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "IsEncrypted": false, 3 | "Values": { 4 | "AzureWebJobsStorage": "", 5 | "FUNCTIONS_WORKER_RUNTIME": "dotnet", 6 | "FUNCTIONS_EXTENSION_VERSION": "4", 7 | "WEBSITE_OWNER_NAME": "abcd1234-abcd-acdc-1234-112233445566+testfaas_group-CentralUSwebspace-Linux", 8 | "WEBSITE_SITE_NAME": "testfaas", 9 | "FUNCTIONS_INPROC_NET8_ENABLED": "1" 10 | // Include this breaks on the latest version of func - Excluding it for now. 11 | //"WEBSITE_INSTANCE_ID": "20367ea8-70b9-41b4-a552-b2a826b3aa0b" 12 | }, 13 | "Host": { 14 | "LocalHttpPort": 17073 15 | } 16 | } -------------------------------------------------------------------------------- /sample/Elastic.Apm.Azure.ServiceBus.Sample/Elastic.Apm.Azure.ServiceBus.Sample.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net8.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /test/iis/AspNetFullFrameworkSampleApp/Data/SampleData.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | using System.ComponentModel.DataAnnotations; 6 | using System.ComponentModel.DataAnnotations.Schema; 7 | using SQLite.CodeFirst; 8 | 9 | namespace AspNetFullFrameworkSampleApp.Data 10 | { 11 | [Table("SampleDataTable")] 12 | public class SampleData 13 | { 14 | [Autoincrement] 15 | public int Id { get; set; } 16 | 17 | [Required] 18 | public string Name { get; set; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /test/instrumentations/Elastic.Apm.StackExchange.Redis.Tests/ConnectionMultiplexerExtensionTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Moq; 3 | using StackExchange.Redis; 4 | using StackExchange.Redis.Profiling; 5 | using Xunit; 6 | 7 | namespace Elastic.Apm.StackExchange.Redis.Tests 8 | { 9 | public class ConnectionMultiplexerExtensionTests 10 | { 11 | [Fact] 12 | public void UseElasticApm_Registers_ElasticApmProfiler() 13 | { 14 | var connection = new Mock(); 15 | 16 | connection.Object.UseElasticApm(); 17 | 18 | connection.Verify(x => 19 | x.RegisterProfiler(It.IsAny>()), Times.Once); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /test/Elastic.Apm.Tests.Utilities/ThreadSafeLongCounter.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | using System.Threading; 6 | 7 | namespace Elastic.Apm.Tests.Utilities 8 | { 9 | public class ThreadSafeLongCounter 10 | { 11 | internal ThreadSafeLongCounter(long initialValue = 0) => _value = initialValue; 12 | 13 | private long _value; 14 | 15 | internal long Value => Volatile.Read(ref _value); 16 | 17 | internal long Increment() => Interlocked.Increment(ref _value); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /test/iis/AspNetFullFrameworkSampleApp/Asmx/Health.asmx.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | using System.Web.Services; 6 | 7 | namespace AspNetFullFrameworkSampleApp.Asmx 8 | { 9 | [WebService(Namespace = "http://tempuri.org/")] 10 | [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] 11 | public class Health : WebService 12 | { 13 | [WebMethod] 14 | public string Ping() => "Ok"; 15 | 16 | [WebMethod] 17 | public string Input(string input) => input; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /test/integrations/Elastic.Apm.Extensions.Hosting.Tests/Elastic.Apm.Extensions.Hosting.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net8.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /test/Elastic.Apm.Tests.Utilities/FlushingTextWriterToLoggerAdaptor.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | using System.IO; 6 | using Elastic.Apm.Logging; 7 | 8 | namespace Elastic.Apm.Tests.Utilities 9 | { 10 | public class FlushingTextWriterToLoggerAdaptor : LineWriterToLoggerAdaptor 11 | { 12 | public FlushingTextWriterToLoggerAdaptor(TextWriter textWriter, LogLevel level = LogLevel.Information) 13 | : base(new FlushingTextWriterToLineWriterAdaptor(textWriter), level) { } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/integrations/applications/SampleAspNetCoreApp/Data/SampleDataContext.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | using Microsoft.AspNetCore.Identity.EntityFrameworkCore; 6 | using Microsoft.EntityFrameworkCore; 7 | 8 | namespace SampleAspNetCoreApp.Data 9 | { 10 | public class SampleDataContext : IdentityDbContext 11 | { 12 | public SampleDataContext(DbContextOptions dbContextOptions) : base(dbContextOptions) { } 13 | 14 | public DbSet SampleTable { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /test/integrations/applications/SampleAspNetCoreApp/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Warning", 5 | "Elastic.Apm": "Trace" 6 | } 7 | }, 8 | "AllowedHosts": "*", 9 | "ElasticApm": { 10 | "ServerUrl": "http://localhost:8200", 11 | "TransactionSampleRate": 1.0, 12 | "CaptureBody": "all", 13 | "CaptureBodyContentTypes": "application/x-www-form-urlencoded*, text/*, application/json*, application/xml*", 14 | "CloudProvider": "none", 15 | "SanitizeFieldNames": "password, passwd, pwd, secret, *key, *token*, *session*, *credit*, *card*, *auth*, set-cookie, *principal*, MySecureCookie" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/Elastic.Apm/Api/Kubernetes/Pod.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | using Elastic.Apm.Api.Constraints; 6 | using Elastic.Apm.Helpers; 7 | 8 | namespace Elastic.Apm.Api.Kubernetes 9 | { 10 | public class Pod 11 | { 12 | [MaxLength] 13 | public string Name { get; set; } 14 | 15 | [MaxLength] 16 | public string Uid { get; set; } 17 | 18 | public override string ToString() => new ToStringBuilder(nameof(Pod)) { { nameof(Name), Name }, { nameof(Uid), Uid } }.ToString(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/Elastic.Apm/ICurrentExecutionSegmentsContainer.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | using Elastic.Apm.Api; 6 | 7 | namespace Elastic.Apm 8 | { 9 | internal interface ICurrentExecutionSegmentsContainer 10 | { 11 | /// 12 | /// Gets or sets the current span 13 | /// 14 | ISpan CurrentSpan { get; set; } 15 | 16 | /// 17 | /// Gets or sets the current transaction 18 | /// 19 | ITransaction CurrentTransaction { get; set; } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /test/Elastic.Apm.Tests.MockApmServer/SpanCountDto.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | using Elastic.Apm.Api; 6 | using Elastic.Apm.Helpers; 7 | 8 | namespace Elastic.Apm.Tests.MockApmServer 9 | { 10 | public class SpanCountDto 11 | { 12 | public int Dropped { get; set; } 13 | public int Started { get; set; } 14 | 15 | public override string ToString() => 16 | new ToStringBuilder(nameof(SpanCount)) { { nameof(Started), Started }, { nameof(Dropped), Dropped } }.ToString(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/Elastic.Apm/BackendComm/CentralConfig/CentralConfigurationKeyValue.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under 2 | // one or more agreements. 3 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 4 | // See the LICENSE file in the project root for more information 5 | 6 | using Elastic.Apm.Config; 7 | 8 | namespace Elastic.Apm.BackendComm.CentralConfig 9 | { 10 | internal class CentralConfigurationKeyValue : ConfigurationKeyValue 11 | { 12 | public CentralConfigurationKeyValue(DynamicConfigurationOption option, string value, string readFrom) 13 | : base(option.ToConfigurationOption(), ConfigurationType.CentralConfig, value, readFrom) { } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/integrations/applications/SampleAspNetCoreApp/Program.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | using Microsoft.AspNetCore; 6 | using Microsoft.AspNetCore.Hosting; 7 | 8 | namespace SampleAspNetCoreApp 9 | { 10 | public class Program 11 | { 12 | public static void Main(string[] args) => CreateWebHostBuilder(args).Build().Run(); 13 | 14 | public static IWebHostBuilder CreateWebHostBuilder(string[] args) => 15 | WebHost.CreateDefaultBuilder(args) 16 | .UseStartup(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /test/Elastic.Apm.Tests.Utilities/SplittingLineWriter.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | namespace Elastic.Apm.Tests.Utilities 6 | { 7 | public class SplittingLineWriter : ILineWriter 8 | { 9 | private readonly ILineWriter[] _lineWriters; 10 | 11 | public SplittingLineWriter(params ILineWriter[] lineWriters) => _lineWriters = lineWriters; 12 | 13 | public void WriteLine(string line) 14 | { 15 | foreach (var lineWriter in _lineWriters) 16 | lineWriter.WriteLine(line); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/Elastic.Apm/Api/Node.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | using Elastic.Apm.Api.Constraints; 6 | using Elastic.Apm.Helpers; 7 | using Elastic.Apm.Libraries.Newtonsoft.Json; 8 | 9 | namespace Elastic.Apm.Api 10 | { 11 | public class Node 12 | { 13 | [JsonProperty("configured_name")] 14 | [MaxLength] 15 | public string ConfiguredName { get; set; } 16 | 17 | public override string ToString() => new ToStringBuilder(nameof(Node)) { { nameof(ConfiguredName), ConfiguredName } }.ToString(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /test/azure/applications/Elastic.AzureFunctionApp.InProcess/Startup.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | using System; 6 | using Elastic.Apm.Azure.Functions; 7 | using Microsoft.Azure.Functions.Extensions.DependencyInjection; 8 | 9 | [assembly: FunctionsStartup(typeof(Elastic.AzureFunctionApp.InProcess.Startup))] 10 | 11 | namespace Elastic.AzureFunctionApp.InProcess; 12 | 13 | internal class Startup : FunctionsStartup 14 | { 15 | public override void Configure(IFunctionsHostBuilder builder) => builder.AddElasticApm(); 16 | } 17 | -------------------------------------------------------------------------------- /test/integrations/applications/WebApiSample/Program.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | using Microsoft.AspNetCore; 6 | using Microsoft.AspNetCore.Hosting; 7 | 8 | namespace WebApiSample 9 | { 10 | public class Program 11 | { 12 | public static void Main(string[] args) => CreateWebHostBuilder(args).Build().Run(); 13 | 14 | public static IWebHostBuilder CreateWebHostBuilder(string[] args) => 15 | WebHost.CreateDefaultBuilder(args) 16 | .UseStartup() 17 | .UseUrls("http://localhost:5050"); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /test/startuphook/Elastic.Apm.StartupHook.Sample/wwwroot/lib/jquery-validation-unobtrusive/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) .NET Foundation. All rights reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use 4 | these files except in compliance with the License. You may obtain a copy of the 5 | License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software distributed 10 | under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 11 | CONDITIONS OF ANY KIND, either express or implied. See the License for the 12 | specific language governing permissions and limitations under the License. 13 | -------------------------------------------------------------------------------- /src/Elastic.Apm/Libraries/Newtonsoft.Json/Linq/JsonPath/QueryFilter.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | #nullable enable 4 | namespace Elastic.Apm.Libraries.Newtonsoft.Json.Linq.JsonPath 5 | { 6 | internal class QueryFilter : PathFilter 7 | { 8 | public QueryFilter(QueryExpression expression) => Expression = expression; 9 | 10 | internal QueryExpression Expression; 11 | 12 | public override IEnumerable ExecuteFilter(JToken root, IEnumerable current, JsonSelectSettings? settings) 13 | { 14 | foreach (var t in current) 15 | { 16 | foreach (var v in t) 17 | { 18 | if (Expression.IsMatch(root, v, settings)) yield return v; 19 | } 20 | } 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /test/integrations/applications/SampleAspNetCoreApp/wwwroot/lib/jquery-validation-unobtrusive/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) .NET Foundation. All rights reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use 4 | these files except in compliance with the License. You may obtain a copy of the 5 | License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software distributed 10 | under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 11 | CONDITIONS OF ANY KIND, either express or implied. See the License for the 12 | specific language governing permissions and limitations under the License. 13 | -------------------------------------------------------------------------------- /sample/ElasticsearchSample/ElasticsearchSample.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net8.0 6 | bfb02fcb-6aa5-47e7-9c9e-5fb512708949 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /test/instrumentations/grpc/GrpcServiceSample/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Hosting; 2 | using Microsoft.Extensions.Hosting; 3 | 4 | namespace GrpcServiceSample 5 | { 6 | public class Program 7 | { 8 | public static void Main(string[] args) => CreateHostBuilder(args).Build().Run(); 9 | 10 | // Additional configuration is required to successfully run gRPC on macOS. 11 | // For instructions on how to configure Kestrel and gRPC clients on macOS, visit https://go.microsoft.com/fwlink/?linkid=2099682 12 | public static IHostBuilder CreateHostBuilder(string[] args) => 13 | Host.CreateDefaultBuilder(args) 14 | .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup(); }); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /test/Elastic.Apm.Tests.Utilities/DummyTestException.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | using System; 6 | 7 | namespace Elastic.Apm.Tests.Utilities 8 | { 9 | internal class DummyTestException : Exception 10 | { 11 | internal const string DefaultMessage = "Dummy exception message"; 12 | 13 | internal DummyTestException() : this(DefaultMessage) { } 14 | 15 | internal DummyTestException(string message) : base(message) { } 16 | 17 | internal DummyTestException(string message, Exception cause) : base(message, cause) { } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /test/integrations/applications/SampleAspNetCoreApp/wwwroot/lib/jquery/.bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery", 3 | "main": "dist/jquery.js", 4 | "license": "MIT", 5 | "ignore": [ 6 | "package.json" 7 | ], 8 | "keywords": [ 9 | "jquery", 10 | "javascript", 11 | "browser", 12 | "library" 13 | ], 14 | "homepage": "https://github.com/jquery/jquery-dist", 15 | "version": "3.3.1", 16 | "_release": "3.3.1", 17 | "_resolution": { 18 | "type": "version", 19 | "tag": "3.3.1", 20 | "commit": "9e8ec3d10fad04748176144f108d7355662ae75e" 21 | }, 22 | "_source": "https://github.com/jquery/jquery-dist.git", 23 | "_target": "^3.3.1", 24 | "_originalSource": "jquery", 25 | "_direct": true 26 | } -------------------------------------------------------------------------------- /test/azure/applications/Elastic.Apm.AzureFunctionApp.Core/Program.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | namespace Elastic.Apm.AzureFunctionApp.Core; 6 | 7 | public static class FunctionName 8 | { 9 | public const string SampleHttpTrigger = nameof(SampleHttpTrigger); 10 | public const string HttpTriggerWithInternalServerError = nameof(HttpTriggerWithInternalServerError); 11 | public const string HttpTriggerWithNotFound = nameof(HttpTriggerWithNotFound); 12 | public const string HttpTriggerWithException = nameof(HttpTriggerWithException); 13 | } 14 | -------------------------------------------------------------------------------- /test/Elastic.Apm.Tests/HelpersTests/LazyContextualInitTestsHelpers.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Elastic.Apm.Helpers; 3 | using Xunit; 4 | // Licensed to Elasticsearch B.V under one or more agreements. 5 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 6 | // See the LICENSE file in the project root for more information 7 | 8 | internal static class LazyContextualInitTestsHelpers 9 | { 10 | public static TheoryData> WaysToCallInit = new() 11 | { 12 | { "IfNotInited?.Init ?? false", (lazyCtxInit, initAction) => lazyCtxInit.IfNotInited?.Init(initAction) ?? false }, 13 | { "Init", (lazyCtxInit, initAction) => lazyCtxInit.Init(initAction) } 14 | }; 15 | } 16 | -------------------------------------------------------------------------------- /test/iis/AspNetFullFrameworkSampleApp/WebformsException.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" CodeBehind="WebformsException.aspx.cs" Inherits="AspNetFullFrameworkSampleApp.WebformsException" %> 2 | 3 | 4 | 5 | 6 | 7 | <%: Title %> - My ASP.NET Application 8 | 9 | 10 |
11 | <% 12 | // throw divide by zero exception and let the framework wrap in a HttpUnhandledException 13 | var zero = 0; 14 | // ReSharper disable once IntDivisionByZero 15 | var result = 1 / zero; 16 | Response.Write(result); 17 | %> 18 |
19 | 20 | -------------------------------------------------------------------------------- /src/Elastic.Apm/Logging/LogLevelSwitch.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under 2 | // one or more agreements. 3 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 4 | // See the LICENSE file in the project root for more information 5 | 6 | namespace Elastic.Apm.Logging 7 | { 8 | /// 9 | /// Dynamically controls the log level 10 | /// 11 | public class LogLevelSwitch 12 | { 13 | private volatile LogLevel _level; 14 | 15 | public LogLevelSwitch(LogLevel level) => _level = level; 16 | 17 | /// 18 | /// Gets or sets the current log level 19 | /// 20 | public LogLevel Level 21 | { 22 | get => _level; 23 | set => _level = value; 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/integrations/Elastic.Apm.Extensions.Logging/ApmErrorLoggingProvider.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | using Microsoft.Extensions.Logging; 6 | 7 | namespace Elastic.Apm.Extensions.Logging 8 | { 9 | internal class ApmErrorLoggingProvider : ILoggerProvider 10 | { 11 | private readonly IApmAgent _apmAgent; 12 | 13 | public ApmErrorLoggingProvider(IApmAgent apmAgent) => _apmAgent = apmAgent; 14 | 15 | public ILogger CreateLogger(string categoryName) 16 | => new ApmErrorLogger(_apmAgent); 17 | 18 | public void Dispose() { } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /test/instrumentations/Elastic.Apm.MongoDb.Tests/Elastic.Apm.MongoDb.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net8.0 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/Elastic.Apm/Report/IntakeResponse.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under 2 | // one or more agreements. 3 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 4 | // See the LICENSE file in the project root for more information 5 | 6 | using System.Collections.Generic; 7 | using Elastic.Apm.Libraries.Newtonsoft.Json; 8 | 9 | namespace Elastic.Apm.Report; 10 | 11 | internal class IntakeResponse 12 | { 13 | [JsonProperty("accepted")] 14 | public int Accepted { get; set; } 15 | 16 | [JsonProperty("errors")] 17 | public IReadOnlyCollection Errors { get; set; } 18 | } 19 | 20 | internal class IntakeError 21 | { 22 | 23 | [JsonProperty("message")] 24 | public string Message { get; set; } 25 | } 26 | -------------------------------------------------------------------------------- /test/integrations/Elastic.Apm.AspNetCore.Tests/TestConfigs/appsettings_valid.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Warning" 5 | } 6 | }, 7 | "AllowedHosts": "*", 8 | "ElasticApm": { 9 | "LogLevel": "Debug", 10 | "ServerUrls": "http://myServerFromTheConfigFile:8080", 11 | "ServiceName": "My.Test.Application", 12 | "ServiceNodeName": "Instance1", 13 | "ServiceVersion": "2.1.0.5", 14 | "Environment": "staging", 15 | "CaptureHeaders": "false", 16 | "TransactionSampleRate": 0.456, 17 | "TransactionMaxSpans": 375, 18 | "CaptureBody": "all", 19 | "CaptureBodyContentTypes" : "application/x-www-form-urlencoded*, text/*, application/json*, application/xml*" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /test/iis/AspNetFullFrameworkSampleApp/Extensions/TempDataExtensions.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under 2 | // one or more agreements. 3 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 4 | // See the LICENSE file in the project root for more information 5 | 6 | using System.Web.Mvc; 7 | 8 | namespace AspNetFullFrameworkSampleApp.Extensions 9 | { 10 | public static class TempDataExtensions 11 | { 12 | public static T Get(this TempDataDictionary tempData, string key) 13 | { 14 | tempData.TryGetValue(key, out var item); 15 | return item == null ? default : (T)item; 16 | } 17 | public static void Put(this TempDataDictionary tempData, string key, T value) => tempData[key] = value; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /test/iis/AspNetFullFrameworkSampleApp/Models/DiagnosticsViewModel.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | using System; 6 | 7 | namespace AspNetFullFrameworkSampleApp.Models 8 | { 9 | public class DiagnosticsViewModel 10 | { 11 | public string EnvironmentVariables { get; set; } 12 | public string InMemoryLogContent { get; set; } 13 | public string LogFileContent { get; set; } 14 | public string LogFilePath { get; set; } 15 | public Exception LogFileReadException { get; set; } 16 | public string LoggingSubsystemInternalLogContent { get; set; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /coverlet.runsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | cobertura 8 | [Elastic.*]*,[ElasticApmStartupHook]* 9 | [Elastic.Apm.Tests]*,[Elastic.Apm.*.Tests]*,[Elastic.Apm.Tests.*]*,[Elastic.Apm.Benchmarks]* 10 | false 11 | false 12 | false 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /sample/Sample.Microsoft.Data.SqlClient/Sample.Microsoft.Data.SqlClient.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | Exe 6 | enable 7 | enable 8 | Sample.SqlClient.DiagnosticSourceListener 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/Elastic.Apm/Api/Outcome.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | using System.Runtime.Serialization; 6 | using Elastic.Apm.Libraries.Newtonsoft.Json; 7 | using Elastic.Apm.Libraries.Newtonsoft.Json.Converters; 8 | 9 | namespace Elastic.Apm.Api 10 | { 11 | [JsonConverter(typeof(StringEnumConverter))] 12 | public enum Outcome 13 | { 14 | [EnumMember(Value = "unknown")] 15 | Unknown = 0, //Make sure Unknown remains the default value 16 | 17 | [EnumMember(Value = "success")] 18 | Success, 19 | 20 | [EnumMember(Value = "failure")] 21 | Failure 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Elastic.Apm/Reflection/CascadePropertyFetcher.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | namespace Elastic.Apm.Reflection 6 | { 7 | internal class CascadePropertyFetcher : PropertyFetcher 8 | { 9 | private readonly PropertyFetcher _innerFetcher; 10 | 11 | public CascadePropertyFetcher(PropertyFetcher innerFetcher, string propertyName) : base(propertyName) => _innerFetcher = innerFetcher; 12 | 13 | public override object Fetch(object obj) 14 | { 15 | var fetchedObject = _innerFetcher.Fetch(obj); 16 | 17 | return base.Fetch(fetchedObject); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/Elastic.Apm/Libraries/Newtonsoft.Json/Linq/JsonPath/ArrayMultipleIndexFilter.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | #nullable enable 4 | namespace Elastic.Apm.Libraries.Newtonsoft.Json.Linq.JsonPath 5 | { 6 | internal class ArrayMultipleIndexFilter : PathFilter 7 | { 8 | public ArrayMultipleIndexFilter(List indexes) => Indexes = indexes; 9 | 10 | internal List Indexes; 11 | 12 | public override IEnumerable ExecuteFilter(JToken root, IEnumerable current, JsonSelectSettings? settings) 13 | { 14 | foreach (var t in current) 15 | { 16 | foreach (var i in Indexes) 17 | { 18 | var v = GetTokenIndex(t, settings, i); 19 | 20 | if (v != null) yield return v; 21 | } 22 | } 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /test/Elastic.Apm.Feature.Tests/Elastic.Apm.Feature.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | 1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /test/Elastic.Apm.Tests.Utilities/SystemDiagnosticsTraceLineWriter.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | using System.Diagnostics; 6 | using Elastic.Apm.Helpers; 7 | 8 | namespace Elastic.Apm.Tests.Utilities 9 | { 10 | public class SystemDiagnosticsTraceLineWriter : ILineWriter 11 | { 12 | private readonly string _prefix; 13 | 14 | public SystemDiagnosticsTraceLineWriter(string prefix = "") => _prefix = prefix; 15 | 16 | public void WriteLine(string text) 17 | { 18 | Trace.WriteLine(TextUtils.PrefixEveryLine(text, _prefix)); 19 | Trace.Flush(); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/Elastic.Apm/Helpers/DbgUtils.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | using System.Runtime.CompilerServices; 6 | using System.Threading; 7 | 8 | namespace Elastic.Apm.Helpers 9 | { 10 | internal class DbgUtils 11 | { 12 | internal static string CurrentThreadDesc => 13 | Thread.CurrentThread.Name == null 14 | ? $"managed ID: {Thread.CurrentThread.ManagedThreadId}" 15 | : $"`{Thread.CurrentThread.Name}' (managed ID: {Thread.CurrentThread.ManagedThreadId})"; 16 | 17 | internal static string CurrentMethodName([CallerMemberName] string caller = null) => caller; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/Elastic.Apm/Helpers/ObjectExtensions.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | using System; 6 | 7 | namespace Elastic.Apm.Helpers 8 | { 9 | internal static class ObjectExtensions 10 | { 11 | public const string NullAsString = ""; 12 | 13 | // ReSharper disable once UnusedMember.Global 14 | public static TResult Let(this T x, Func func) => func(x); 15 | 16 | public static void Let(this T x, Action action) => action(x); 17 | 18 | public static string AsNullableToString(this object value) => value?.ToString() ?? NullAsString; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/profiler/Elastic.Apm.Profiler.IntegrationsGenerator/Target.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under 2 | // one or more agreements. 3 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 4 | // See the LICENSE file in the project root for more information 5 | 6 | using YamlDotNet.Serialization; 7 | 8 | namespace Elastic.Apm.Profiler.IntegrationsGenerator 9 | { 10 | public class Target 11 | { 12 | [YamlIgnore] 13 | public string Nuget { get; set; } 14 | public string Assembly { get; set; } 15 | public string Type { get; set; } 16 | public string Method { get; set; } 17 | public string[] SignatureTypes { get; set; } 18 | public string MinimumVersion { get; set; } 19 | public string MaximumVersion { get; set; } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/Elastic.Apm/Model/SpanTimerKey.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under 2 | // one or more agreements. 3 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 4 | // See the LICENSE file in the project root for more information 5 | 6 | namespace Elastic.Apm.Model 7 | { 8 | /// 9 | /// Encapsulates type and subtype 10 | /// 11 | internal readonly record struct SpanTimerKey 12 | { 13 | public SpanTimerKey(string type, string subType) => (Type, SubType) = (type, subType); 14 | public SpanTimerKey(string type) => (Type, SubType) = (type, null); 15 | 16 | public readonly string Type { get; } 17 | public readonly string SubType { get; } 18 | 19 | public static SpanTimerKey AppSpanType => new("app"); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/startuphook/ElasticApmAgentStartupHook/ElasticApmAgentStartupHook.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | netstandard2.0 4 | ElasticApmAgentStartupHook 5 | false 6 | ElasticApmStartupHook 7 | $(DefineConstants);STARTUP_HOOKS 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /test/profiler/Elastic.Apm.Profiler.Managed.Tests/DuckTyping/Methods/ProxiesDefinitions/IDictioValue.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under 2 | // one or more agreements. 3 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 4 | // See the LICENSE file in the project root for more information 5 | // 6 | // 7 | // Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. 8 | // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. 9 | // 10 | 11 | namespace Elastic.Apm.Profiler.Managed.Tests.DuckTyping.Methods.ProxiesDefinitions 12 | { 13 | public interface IDictioValue { } 14 | } 15 | -------------------------------------------------------------------------------- /test/profiler/applications/SqlClientSample/SqlClientSample.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 4.8.6 5 | Exe 6 | net462;net8.0 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /test/iis/AspNetFullFrameworkSampleApp/Models/LoginViewModel.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under 2 | // one or more agreements. 3 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 4 | // See the LICENSE file in the project root for more information 5 | 6 | using System.ComponentModel.DataAnnotations; 7 | 8 | namespace AspNetFullFrameworkSampleApp.Models 9 | { 10 | public class LoginViewModel 11 | { 12 | [Required] 13 | [Display(Name = "Email")] 14 | [EmailAddress] 15 | public string Email { get; set; } 16 | 17 | [Required] 18 | [DataType(DataType.Password)] 19 | [Display(Name = "Password")] 20 | public string Password { get; set; } 21 | 22 | [Display(Name = "Remember me?")] 23 | public bool RememberMe { get; set; } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /docs/reference/images/dynamic-config.svg: -------------------------------------------------------------------------------- 1 | DynamicDynamic -------------------------------------------------------------------------------- /test/Elastic.Apm.Tests/HelpersTests/CollectionExtensionsTests.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | using System.Collections.Generic; 6 | using Elastic.Apm.Helpers; 7 | using FluentAssertions; 8 | using Xunit; 9 | 10 | namespace Elastic.Apm.Tests.HelpersTests 11 | { 12 | public class CollectionExtensionsTests 13 | { 14 | [Fact] 15 | public void IsEmpty_List_test() 16 | { 17 | var list = new List(); 18 | list.IsEmpty().Should().BeTrue(); 19 | list.Add(123); 20 | list.IsEmpty().Should().BeFalse(); 21 | list.Clear(); 22 | list.IsEmpty().Should().BeTrue(); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /benchmarks/Elastic.Apm.Benchmarks/TraceParentBenchmarks.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | using System.Diagnostics; 6 | using BenchmarkDotNet.Attributes; 7 | using Elastic.Apm.DistributedTracing; 8 | 9 | namespace Elastic.Apm.Benchmarks 10 | { 11 | [MemoryDiagnoser] 12 | public class TraceParentBenchmarks 13 | { 14 | [Benchmark] 15 | public void ParseTraceparentHeader() 16 | { 17 | const string traceParent = "00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01"; 18 | 19 | var res = TraceContext.TryExtractTracingData(traceParent); 20 | Debug.WriteLine($"{res}"); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /benchmarks/Elastic.Apm.Profiling/Elastic.Apm.Profiling.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net8.0 6 | enable 7 | enable 8 | false 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/Elastic.Apm/Cloud/ICloudMetadataProvider.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under 2 | // one or more agreements. 3 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 4 | // See the LICENSE file in the project root for more information 5 | 6 | using System.Threading.Tasks; 7 | 8 | namespace Elastic.Apm.Cloud 9 | { 10 | /// 11 | /// Provides metadata for a cloud provider 12 | /// 13 | public interface ICloudMetadataProvider 14 | { 15 | /// 16 | /// The name of the cloud provider 17 | /// 18 | string Provider { get; } 19 | 20 | /// 21 | /// Retrieves the cloud metadata for the provider 22 | /// 23 | /// 24 | Task GetMetadataAsync(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /test/Elastic.Apm.Tests.Utilities/XUnit/MemberData.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | using System; 5 | using System.Collections.Generic; 6 | 7 | namespace Elastic.Apm.Tests.Utilities.XUnit; 8 | 9 | public static class MemberData 10 | { 11 | public static IEnumerable TestWithDiagnosticSourceOnly() 12 | { 13 | yield return new object[] { false }; 14 | // 15 | // Skip "DiagnosticSourceOnly" tests on .NET 7 16 | // until https://github.com/dotnet/aspnetcore/issues/45233 is resolved. 17 | // 18 | if (Environment.Version.Major < 7) 19 | yield return new object[] { true }; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /test/iis/AspNetFullFrameworkSampleApp/Views/Database/Create.cshtml: -------------------------------------------------------------------------------- 1 | @model CreateSampleDataViewModel 2 | 3 | @using (Html.BeginForm("Create", "Database", FormMethod.Post, new { id = "createForm", @class = "form-horizontal", role = "form" })) 4 | { 5 | @Html.AntiForgeryToken() 6 |

Add a new sample

7 |
8 | @Html.ValidationSummary(true, "", new { @class = "text-danger" }) 9 |
10 | @Html.Hidden("samples.Index", "index") 11 | @Html.Label("samples[index].Name") 12 | @Html.TextBox("samples[index].Name", "", new { @class = "form-control" }) 13 | @Html.ValidationMessage("samples[index].Name", "", new { @class = "text-danger" }) 14 |
15 |
16 | 17 |
18 | } -------------------------------------------------------------------------------- /test/integrations/applications/SampleAspNetCoreApp/Views/Shared/_LoginPartial.cshtml: -------------------------------------------------------------------------------- 1 | @using Microsoft.AspNetCore.Identity 2 | @inject SignInManager SignInManager 3 | @inject UserManager UserManager 4 | 5 | @if (SignInManager.IsSignedIn(User)) 6 | { 7 | 15 | } 16 | else 17 | { 18 | 26 | } -------------------------------------------------------------------------------- /src/Elastic.Apm/Api/Kubernetes/KubernetesMetadata.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | using Elastic.Apm.Api.Constraints; 6 | using Elastic.Apm.Helpers; 7 | 8 | namespace Elastic.Apm.Api.Kubernetes 9 | { 10 | public class KubernetesMetadata 11 | { 12 | [MaxLength] 13 | public string Namespace { get; set; } 14 | 15 | public Node Node { get; set; } 16 | 17 | public Pod Pod { get; set; } 18 | 19 | public override string ToString() => 20 | new ToStringBuilder(nameof(KubernetesMetadata)) { { nameof(Namespace), Namespace }, { nameof(Node), Node }, { nameof(Pod), Pod } } 21 | .ToString(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Elastic.Apm/Model/OTel.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under 2 | // one or more agreements. 3 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 4 | // See the LICENSE file in the project root for more information 5 | 6 | using System.Collections.Generic; 7 | 8 | namespace Elastic.Apm.Model 9 | { 10 | /// 11 | /// OTel contains unmapped OpenTelemetry attributes. 12 | /// 13 | public class OTel 14 | { 15 | /// 16 | /// Attributes hold the unmapped OpenTelemetry attributes. 17 | /// 18 | public Dictionary Attributes { get; set; } 19 | 20 | /// 21 | /// SpanKind holds the incoming OpenTelemetry span kind. 22 | /// 23 | public string SpanKind { get; set; } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /sample/HttpListenerSample/README.md: -------------------------------------------------------------------------------- 1 | ## HttpListenerSample ## 2 | 3 | The goal of this sample is to show you how you can use the Public Agent API for frameworks that are currently not covered by auto-instrumentation features. 4 | 5 | This is a simple application that listens to HTTP requests on http://localhost:8080 and does two things within each request: 6 | - It generates a random number 7 | - It returns the number of stars on the Elastic APM .NET Agent GitHub repository 8 | 9 | The Elastic APM agent traces the incoming requests with the Public Agent API. 10 | 11 | The agent starts a transaction for every incoming request and it creates a span with the Public Agent API each time the GenerateRandomNumber method is executed. The HTTP call in the GetNumberOfStars method is automatically captured by the agent. -------------------------------------------------------------------------------- /test/Elastic.Apm.Tests.MockApmServer/DroppedSpanStatsDto.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | using Elastic.Apm.Api; 6 | using Elastic.Apm.Libraries.Newtonsoft.Json; 7 | 8 | namespace Elastic.Apm.Tests.MockApmServer 9 | { 10 | public class DroppedSpanStatsDto 11 | { 12 | [JsonProperty("destination_service_resource")] 13 | public string DestinationServiceResource { get; } 14 | 15 | [JsonProperty("duration.count")] 16 | public int DurationCount { get; set; } 17 | 18 | [JsonProperty("duration.sum.us")] 19 | public double DurationSumUs { get; set; } 20 | 21 | public Outcome Outcome { get; } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /test/integrations/applications/SampleAspNetCoreApp/Views/Home/AddSampleData.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | } 3 | 4 |
5 | 8 | 9 |
10 |
11 | 12 | 13 | 14 |
15 |
16 | 17 | 18 | 19 | 20 | 21 |
-------------------------------------------------------------------------------- /test/profiler/Elastic.Apm.Profiler.Managed.Tests/DuckTyping/Methods/ProxiesDefinitions/TestEnum2.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under 2 | // one or more agreements. 3 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 4 | // See the LICENSE file in the project root for more information 5 | // 6 | // 7 | // Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. 8 | // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. 9 | // 10 | 11 | namespace Elastic.Apm.Profiler.Managed.Tests.DuckTyping.Methods.ProxiesDefinitions 12 | { 13 | public enum TestEnum2 14 | { 15 | Primero, 16 | Segundo 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/Elastic.Apm/Api/MetricSample.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | using System.Collections.Generic; 6 | using Elastic.Apm.Helpers; 7 | 8 | namespace Elastic.Apm.Api 9 | { 10 | /// 11 | /// A single metric sample. 12 | /// 13 | public class MetricSample 14 | { 15 | public MetricSample(string key, double value) 16 | => KeyValue = new KeyValuePair(key, value); 17 | 18 | internal KeyValuePair KeyValue { get; set; } 19 | 20 | public override string ToString() => new ToStringBuilder(nameof(MetricSample)) { { KeyValue.Key, KeyValue.Value } }.ToString(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /test/iis/AspNetFullFrameworkSampleApp/Views/Shared/_LoginPartial.cshtml: -------------------------------------------------------------------------------- 1 | @using Microsoft.AspNet.Identity 2 | 3 | -------------------------------------------------------------------------------- /test/integrations/applications/SampleAspNetCoreApp/Views/Home/DistributedTracingMiniSample.cshtml: -------------------------------------------------------------------------------- 1 | @model List 2 | 3 |
4 | 9 | 10 |
11 | Data from the WebApiSample service: 12 | 13 | @if (ViewData["Fail"] == null) 14 | { 15 |
    16 | @{ 17 | foreach (var item in Model) 18 | { 19 |
  • @item
  • 20 | } 21 | } 22 |
23 | } 24 | else 25 | { 26 | @ViewData["Fail"] 27 | } 28 |
-------------------------------------------------------------------------------- /test/integrations/applications/SampleConsoleNetCoreApp/SampleConsoleNetCoreApp.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net8.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | PreserveNewest 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /test/Elastic.Apm.Tests.Utilities/LocalPort.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under 2 | // one or more agreements. 3 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 4 | // See the LICENSE file in the project root for more information 5 | 6 | using System.Net; 7 | using System.Net.Sockets; 8 | 9 | namespace Elastic.Apm.Tests.Utilities 10 | { 11 | public class LocalPort 12 | { 13 | private static readonly IPEndPoint DefaultLoopbackEndpoint = new IPEndPoint(IPAddress.Loopback, 0); 14 | 15 | public static int GetAvailablePort() 16 | { 17 | using (var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)) 18 | { 19 | socket.Bind(DefaultLoopbackEndpoint); 20 | return ((IPEndPoint)socket.LocalEndPoint).Port; 21 | } 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /test/Elastic.Apm.Tests.Utilities/TestEnvironmentVariables.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under 2 | // one or more agreements. 3 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 4 | // See the LICENSE file in the project root for more information 5 | 6 | using System.Collections; 7 | using Elastic.Apm.Helpers; 8 | 9 | namespace Elastic.Apm.Tests.Utilities 10 | { 11 | public class TestEnvironmentVariables : IEnvironmentVariables 12 | { 13 | private readonly Hashtable _hashTable; 14 | 15 | public TestEnvironmentVariables() => _hashTable = new Hashtable(); 16 | 17 | public string this[string key] 18 | { 19 | get => _hashTable[key] as string; 20 | set => _hashTable[key] = value; 21 | } 22 | 23 | public IDictionary GetEnvironmentVariables() => _hashTable; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /test/iis/AspNetFullFrameworkSampleApp/Areas/MyArea/MyAreaRegistration.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under 2 | // one or more agreements. 3 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 4 | // See the LICENSE file in the project root for more information 5 | 6 | using System.Web.Mvc; 7 | 8 | namespace AspNetFullFrameworkSampleApp.Areas.MyArea 9 | { 10 | public class MyAreaRegistration : AreaRegistration 11 | { 12 | public override void RegisterArea(AreaRegistrationContext context) => 13 | context.MapRoute("MyArea_Default", 14 | "MyArea/{controller}/{action}/{id}", 15 | new { action = "Index", id = UrlParameter.Optional }, 16 | new[] { "AspNetFullFrameworkSampleApp.Areas.MyArea.Controllers" }); 17 | 18 | public override string AreaName => "MyArea"; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /docs/reference/setup-azure-cosmosdb.md: -------------------------------------------------------------------------------- 1 | --- 2 | mapped_pages: 3 | - https://www.elastic.co/guide/en/apm/agent/dotnet/current/setup-azure-cosmosdb.html 4 | applies_to: 5 | stack: 6 | serverless: 7 | observability: 8 | product: 9 | apm_agent_dotnet: ga 10 | --- 11 | 12 | # Azure Cosmos DB [setup-azure-cosmosdb] 13 | 14 | 15 | ## Quick start [_quick_start_11] 16 | 17 | Instrumentation can be enabled for Azure Cosmos DB by referencing [`Elastic.Apm.Azure.CosmosDb`](https://www.nuget.org/packages/Elastic.Apm.Azure.CosmosDb) package and subscribing to diagnostic events. 18 | 19 | ```csharp 20 | Agent.Subscribe(new AzureCosmosDbDiagnosticsSubscriber()); 21 | ``` 22 | 23 | Diagnostic events from `Microsoft.Azure.Cosmos`, `Microsoft.Azure.DocumentDb`, and `Microsoft.Azure.DocumentDb.Core` are captured as DB spans. 24 | 25 | -------------------------------------------------------------------------------- /src/Elastic.Apm/Consts.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | namespace Elastic.Apm 6 | { 7 | internal static class Consts 8 | { 9 | internal const int PropertyMaxLength = 1024; 10 | 11 | internal const string AgentName = "dotnet"; 12 | 13 | internal const string Redacted = "[REDACTED]"; 14 | internal const string NotProvided = "[NOT_PROVIDED]"; 15 | 16 | 17 | internal const string ActivationK8SAttach = "k8s-attach"; 18 | internal const string ActivationMethodNuGet = "nuget"; 19 | internal const string ActivationMethodProfiler = "profiler"; 20 | internal const string ActivationMethodStartupHook = "startup-hook"; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /test/integrations/Elastic.Apm.Extensions.Logging.Tests/Elastic.Apm.Extensions.Logging.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net8.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /test/instrumentations/Elastic.Apm.StackExchange.Redis.Tests/Elastic.Apm.StackExchange.Redis.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | false 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/instrumentations/Elastic.Apm.MongoDb/Constants.cs: -------------------------------------------------------------------------------- 1 | // Based on the elastic-apm-mongo project by Vadim Hatsura (@vhatsura) 2 | // https://github.com/vhatsura/elastic-apm-mongo 3 | // Licensed to Elasticsearch B.V under the Apache 2.0 License. 4 | // Elasticsearch B.V licenses this file, including any modifications, to you under the Apache 2.0 License. 5 | // See the LICENSE file in the project root for more information. 6 | 7 | namespace Elastic.Apm.MongoDb 8 | { 9 | internal static class Constants 10 | { 11 | internal const string MongoDiagnosticName = "MongoDB.Driver"; 12 | 13 | public static class Events 14 | { 15 | internal const string CommandStart = nameof(CommandStart); 16 | internal const string CommandEnd = nameof(CommandEnd); 17 | internal const string CommandFail = nameof(CommandFail); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /sample/WorkerServiceSample/Worker.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | 3 | namespace WorkerServiceSample 4 | { 5 | public class Worker : BackgroundService 6 | { 7 | private readonly IHttpClientFactory _httpClientFactory; 8 | private static readonly ActivitySource ActivitySource = new("MyActivitySource"); 9 | 10 | public Worker(IHttpClientFactory httpClientFactory) => _httpClientFactory = httpClientFactory; 11 | 12 | protected override async Task ExecuteAsync(CancellationToken stoppingToken) 13 | { 14 | while (!stoppingToken.IsCancellationRequested) 15 | { 16 | using var activity = ActivitySource.StartActivity("UnitOfWork"); 17 | var client = _httpClientFactory.CreateClient(); 18 | await client.GetAsync("https://www.elastic.co", stoppingToken); 19 | await Task.Delay(5000, stoppingToken); 20 | } 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Elastic.Apm/Api/Database.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | using Elastic.Apm.Api.Constraints; 6 | 7 | namespace Elastic.Apm.Api 8 | { 9 | /// 10 | /// An object containing contextual data for database spans. 11 | /// It can be attached to an through 12 | /// 13 | public class Database 14 | { 15 | public const string TypeElasticsearch = "elasticsearch"; 16 | public const string TypeSql = "sql"; 17 | 18 | public string Instance { get; set; } 19 | 20 | [MaxLength(10_000)] 21 | public string Statement { get; set; } 22 | 23 | public string Type { get; set; } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Elastic.Apm/Api/User.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | using Elastic.Apm.Api.Constraints; 6 | using Elastic.Apm.Helpers; 7 | using Elastic.Apm.Libraries.Newtonsoft.Json; 8 | 9 | namespace Elastic.Apm.Api 10 | { 11 | public class User 12 | { 13 | [MaxLength] 14 | public string Email { get; set; } 15 | 16 | [MaxLength] 17 | public string Id { get; set; } 18 | 19 | [MaxLength] 20 | [JsonProperty("username")] 21 | public string UserName { get; set; } 22 | 23 | public override string ToString() => 24 | new ToStringBuilder(nameof(User)) { { nameof(Id), Id }, { nameof(UserName), UserName }, { nameof(Email), Email } }.ToString(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/profiler/Elastic.Apm.Profiler.Managed/ExecutionSegmentExtensions.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under 2 | // one or more agreements. 3 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 4 | // See the LICENSE file in the project root for more information 5 | 6 | using System; 7 | using System.Runtime.CompilerServices; 8 | using Elastic.Apm.Api; 9 | 10 | namespace Elastic.Apm.Profiler.Managed 11 | { 12 | internal static class ExecutionSegmentExtensions 13 | { 14 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 15 | public static void EndCapturingException(this IExecutionSegment segment, Exception exception) 16 | { 17 | if (segment is not null) 18 | { 19 | if (exception is not null) 20 | segment.CaptureException(exception); 21 | 22 | segment.End(); 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /test/Elastic.Apm.Tests.Utilities/TestHostNameDetector.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under 2 | // one or more agreements. 3 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 4 | // See the LICENSE file in the project root for more information 5 | 6 | using Elastic.Apm.Config; 7 | using Elastic.Apm.Helpers; 8 | using Elastic.Apm.Logging; 9 | 10 | namespace Elastic.Apm.Tests.Utilities; 11 | 12 | internal class TestHostNameDetector : IHostNameDetector 13 | { 14 | private readonly string _hostName; 15 | 16 | public TestHostNameDetector(IConfiguration configuration) => 17 | _hostName = configuration?.HostName ?? "MY_COMPUTER"; 18 | 19 | public TestHostNameDetector(string detectedHostName) => 20 | _hostName = detectedHostName; 21 | 22 | public string GetDetectedHostName(IApmLogger logger) => _hostName; 23 | } 24 | -------------------------------------------------------------------------------- /src/azure/Elastic.Apm.Azure.Storage/FileShareUrl.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under 2 | // one or more agreements. 3 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 4 | // See the LICENSE file in the project root for more information 5 | 6 | using System; 7 | 8 | namespace Elastic.Apm.Azure.Storage 9 | { 10 | internal class FileShareUrl : StorageUrl 11 | { 12 | public static bool TryCreate(string url, out FileShareUrl fileShareUrl) 13 | { 14 | if (Uri.TryCreate(url, UriKind.Absolute, out var uri)) 15 | { 16 | fileShareUrl = new FileShareUrl(uri); 17 | return true; 18 | } 19 | 20 | fileShareUrl = null; 21 | return false; 22 | } 23 | 24 | public FileShareUrl(Uri url) : base(url) => ResourceName = url.AbsolutePath.TrimStart('/'); 25 | 26 | public string ResourceName { get; } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /test/Elastic.Apm.Tests.Utilities/ToAllSinksLogger.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | using System; 6 | using Elastic.Apm.Logging; 7 | using Xunit.Abstractions; 8 | 9 | namespace Elastic.Apm.Tests.Utilities 10 | { 11 | public class ToAllSinksLogger : LineWriterToLoggerAdaptor 12 | { 13 | public ToAllSinksLogger(ITestOutputHelper xUnitOutputHelper, LogLevel level = LogLevel.Trace) 14 | : base( 15 | new SplittingLineWriter( 16 | new SystemDiagnosticsTraceLineWriter(" "), 17 | new FlushingTextWriterToLineWriterAdaptor(Console.Out), 18 | new XunitOutputToLineWriterAdaptor(xUnitOutputHelper)) 19 | , level) 20 | { } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /test/iis/AspNetFullFrameworkSampleApp/Views/Account/ForgotPassword.cshtml: -------------------------------------------------------------------------------- 1 | @model ForgotPasswordViewModel 2 | @{ 3 | ViewBag.Title = "Forgot your password?"; 4 | } 5 | 6 |

@ViewBag.Title

7 | 8 | @using (Html.BeginForm("ForgotPassword", "Account", FormMethod.Post, new { @class = "form-horizontal", role = "form" })) 9 | { 10 | @Html.AntiForgeryToken() 11 |

Enter your email.

12 |
13 | @Html.ValidationSummary("", new { @class = "text-danger" }) 14 |
15 | @Html.LabelFor(m => m.Email) 16 | @Html.TextBoxFor(m => m.Email, new { @class = "form-control" }) 17 |
18 |
19 | 20 |
21 | } 22 | 23 | @section Scripts { 24 | @Scripts.Render("~/bundles/jqueryval") 25 | } 26 | -------------------------------------------------------------------------------- /test/instrumentations/Elastic.Clients.Elasticsearch.Tests/README.md: -------------------------------------------------------------------------------- 1 | This test project contains tests for the [`Elastic.Clients.Elasticsearch`](https://www.nuget.org/packages/Elastic.Clients.Elasticsearch) package, which is the "new" Elasticsearch .NET client. 2 | 3 | [`Elastic.Clients.Elasticsearch`](https://www.nuget.org/packages/Elastic.Clients.Elasticsearch) emits OpenTelemetry compatible `Activity` instances by default, so there is no corresponding instrumentation package in the agent. 4 | Spans emitted by this package are captured via the OpenTelemetry bridge. 5 | 6 | The `Elastic.Apm.Elasticsearch` and the `Elastic.Apm.Elasticsearch.Tests` packages in this repository cover the "old" Elasticsearch client (which is the [`Elasticsearch.Net`](Elasticsearch.Net) package and NEST on top of it). That instrumentation is based on classic DiagnosticSource and pre-dates OpenTelemetry. -------------------------------------------------------------------------------- /test/instrumentations/Elastic.Apm.Elasticsearch.Tests/Elastic.Apm.Elasticsearch.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | false 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /test/instrumentations/grpc/GrpcServiceSample/Services/GreeterService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | using Grpc.Core; 4 | using Microsoft.Extensions.Logging; 5 | 6 | // ReSharper disable once CheckNamespace 7 | namespace GrpcServiceSample 8 | { 9 | public class GreeterService : Greeter.GreeterBase 10 | { 11 | // ReSharper disable once NotAccessedField.Local 12 | private readonly ILogger _logger; 13 | 14 | public GreeterService(ILogger logger) => _logger = logger; 15 | 16 | public override Task SayHello(HelloRequest request, ServerCallContext context) => 17 | Task.FromResult(new HelloReply { Message = "Hello " + request.Name }); 18 | 19 | public override Task ThrowAnException(HelloRequest request, ServerCallContext context) => throw new Exception("Test Exception"); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/Elastic.Apm/Api/Links.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under 2 | // one or more agreements. 3 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 4 | // See the LICENSE file in the project root for more information 5 | 6 | using Elastic.Apm.Api.Constraints; 7 | using Elastic.Apm.Libraries.Newtonsoft.Json; 8 | 9 | namespace Elastic.Apm.Api 10 | { 11 | /// 12 | /// Represents a span link. 13 | /// Links holds links to other spans, potentially in other traces. 14 | /// 15 | public class SpanLink 16 | { 17 | public SpanLink(string spanId, string traceId) 18 | { 19 | SpanId = spanId; 20 | TraceId = traceId; 21 | } 22 | 23 | [JsonProperty("span_id")] 24 | [MaxLength] 25 | public string SpanId { get; } 26 | 27 | [JsonProperty("trace_id")] 28 | [MaxLength] 29 | public string TraceId { get; } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Elastic.Apm/Report/IPayloadSender.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | using Elastic.Apm.Api; 8 | 9 | namespace Elastic.Apm.Report 10 | { 11 | public interface IPayloadSender 12 | { 13 | void QueueError(IError error); 14 | 15 | void QueueMetrics(IMetricSet metrics); 16 | 17 | void QueueSpan(ISpan span); 18 | 19 | void QueueTransaction(ITransaction transaction); 20 | } 21 | 22 | public interface IPayloadSenderWithFilters 23 | { 24 | bool AddFilter(Func transactionFilter); 25 | bool AddFilter(Func spanFilter); 26 | bool AddFilter(Func errorFilter); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /test/profiler/Elastic.Apm.Profiler.Managed.Tests/DuckTyping/Properties/ValueType/ProxiesDefinitions/IObscureErrorDuckType.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under 2 | // one or more agreements. 3 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 4 | // See the LICENSE file in the project root for more information 5 | // 6 | // 7 | // Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. 8 | // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. 9 | // 10 | 11 | namespace Elastic.Apm.Profiler.Managed.Tests.DuckTyping.Properties.ValueType.ProxiesDefinitions 12 | { 13 | public interface IObscureErrorDuckType 14 | { 15 | int PublicGetValueType { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /benchmarks/Elastic.Apm.Benchmarks/Elastic.Apm.Benchmarks.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net8.0 6 | false 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /test/Elastic.Apm.Feature.Tests/README.md: -------------------------------------------------------------------------------- 1 | # Elastic.Apm.Feature.Tests 2 | 3 | This project contains [gherkin](https://cucumber.io/docs/gherkin/) specifications and their implementation in C# which test the agent. 4 | 5 | The specification from the `/Features` folder is synced from the [`github.com/elastic/apm`](https://github.com/elastic/apm) repository from the [`tests/agents/gherkin-specs`](https://github.com/elastic/apm/tree/main/tests/agents/gherkin-specs) folder via automated PRs. 6 | Every APM Agent implements these spec files and therefore they are managed centrally in the `/elastic/apm` repository. 7 | 8 | Spec files (files with `.feature` extension) in this project should not be changed - in case we need to adapt the specification, a PR in the [`github.com/elastic/apm`](https://github.com/elastic/apm) needs to be opened. 9 | That way changes in the spec files are synced across all APM Agents. -------------------------------------------------------------------------------- /test/iis/AspNetFullFrameworkSampleApp/Services/Auth/ApplicationSignInManager.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under 2 | // one or more agreements. 3 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 4 | // See the LICENSE file in the project root for more information 5 | 6 | using AspNetFullFrameworkSampleApp.Models; 7 | using Microsoft.AspNet.Identity.Owin; 8 | using Microsoft.Owin.Security; 9 | 10 | namespace AspNetFullFrameworkSampleApp.Services.Auth 11 | { 12 | /// 13 | /// ASP.NET Identity sign in manager for this application 14 | /// 15 | public class ApplicationSignInManager : SignInManager 16 | { 17 | public ApplicationSignInManager(ApplicationUserManager userManager, IAuthenticationManager authenticationManager) 18 | : base(userManager, authenticationManager) 19 | { 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/Elastic.Apm/Config/Net4FullFramework/AppSettingsConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | #if NETFRAMEWORK 5 | #nullable enable 6 | 7 | using Elastic.Apm.Logging; 8 | 9 | namespace Elastic.Apm.Config.Net4FullFramework; 10 | 11 | internal class AppSettingsConfiguration : FallbackToEnvironmentConfigurationBase 12 | { 13 | public AppSettingsConfiguration(IApmLogger? logger = null) 14 | : this(logger, 15 | new ConfigurationDefaults { DebugName = nameof(AppSettingsConfiguration) } 16 | ) { } 17 | 18 | internal AppSettingsConfiguration(IApmLogger? logger, ConfigurationDefaults defaults) 19 | : base(logger, defaults, new AppSettingsConfigurationKeyValueProvider(logger)) { } 20 | } 21 | #endif 22 | -------------------------------------------------------------------------------- /sample/WebApiExample/Controllers/WeatherForecastController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | 3 | namespace WebApiExample.Controllers; 4 | 5 | [ApiController] 6 | [Route("[controller]")] 7 | public class WeatherForecastController : ControllerBase 8 | { 9 | private static readonly string[] Summaries = 10 | [ 11 | "Freezing", 12 | "Bracing", 13 | "Chilly", 14 | "Cool", 15 | "Mild", 16 | "Warm", 17 | "Balmy", 18 | "Hot", 19 | "Sweltering", 20 | "Scorching" 21 | ]; 22 | 23 | [HttpGet(Name = "GetWeatherForecast")] 24 | public IEnumerable Get() => 25 | Enumerable.Range(1, 5) 26 | .Select(index => new WeatherForecast 27 | { 28 | Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)), 29 | TemperatureC = Random.Shared.Next(-20, 55), 30 | Summary = Summaries[Random.Shared.Next(Summaries.Length)] 31 | }) 32 | .ToArray(); 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/Elastic.Apm/Filters/ErrorContextSanitizerFilter.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under 2 | // one or more agreements. 3 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 4 | // See the LICENSE file in the project root for more information 5 | 6 | using Elastic.Apm.Api; 7 | using Elastic.Apm.Config; 8 | using Elastic.Apm.Model; 9 | 10 | namespace Elastic.Apm.Filters 11 | { 12 | /// 13 | /// A filter that sanitizes fields on error based on the setting 14 | /// 15 | internal class ErrorContextSanitizerFilter 16 | { 17 | public static IError Filter(IError error) 18 | { 19 | if (error is Error realError && realError.Configuration != null) 20 | Sanitization.SanitizeHeadersInContext(realError.Context, realError.Configuration); 21 | 22 | return error; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /test/Elastic.Apm.Tests.Utilities/XunitOutputToLineWriterAdaptor.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | using Elastic.Apm.Helpers; 6 | using Xunit.Abstractions; 7 | 8 | namespace Elastic.Apm.Tests.Utilities 9 | { 10 | public class XunitOutputToLineWriterAdaptor : ILineWriter 11 | { 12 | private readonly string _prefix; 13 | private readonly ITestOutputHelper _xUnitOutputHelper; 14 | 15 | public XunitOutputToLineWriterAdaptor(ITestOutputHelper xUnitOutputHelper, string prefix = "") 16 | { 17 | _xUnitOutputHelper = xUnitOutputHelper; 18 | _prefix = prefix; 19 | } 20 | 21 | public void WriteLine(string text) => _xUnitOutputHelper.WriteLine(TextUtils.PrefixEveryLine(text, _prefix)); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /test/profiler/Elastic.Apm.Profiler.Managed.Tests/DuckTyping/Properties/ReferenceType/ProxiesDefinitions/IObscureErrorDuckType.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under 2 | // one or more agreements. 3 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 4 | // See the LICENSE file in the project root for more information 5 | // 6 | // 7 | // Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. 8 | // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. 9 | // 10 | 11 | namespace Elastic.Apm.Profiler.Managed.Tests.DuckTyping.Properties.ReferenceType.ProxiesDefinitions 12 | { 13 | public interface IObscureErrorDuckType 14 | { 15 | string PublicGetReferenceType { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/profiler/Elastic.Apm.Profiler.Managed/DuckTyping/DuckCopyAttribute.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under 2 | // one or more agreements. 3 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 4 | // See the LICENSE file in the project root for more information 5 | // 6 | // 7 | // Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. 8 | // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. 9 | // 10 | 11 | using System; 12 | 13 | namespace Elastic.Apm.Profiler.Managed.DuckTyping 14 | { 15 | /// 16 | /// Duck copy struct attribute 17 | /// 18 | [AttributeUsage(AttributeTargets.Struct, AllowMultiple = false)] 19 | public class DuckCopyAttribute : Attribute { } 20 | } 21 | -------------------------------------------------------------------------------- /test/profiler/Elastic.Apm.Profiler.Managed.Tests/DuckTyping/Properties/TypeChaining/ProxiesDefinitions/IObscureErrorDuckType.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under 2 | // one or more agreements. 3 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 4 | // See the LICENSE file in the project root for more information 5 | // 6 | // 7 | // Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. 8 | // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. 9 | // 10 | 11 | namespace Elastic.Apm.Profiler.Managed.Tests.DuckTyping.Properties.TypeChaining.ProxiesDefinitions 12 | { 13 | public interface IObscureErrorDuckType 14 | { 15 | IDummyFieldObject PublicGetSelfType { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/Elastic.Apm/Libraries/Newtonsoft.Json/Linq/JsonPath/QueryScanFilter.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | #nullable enable 4 | namespace Elastic.Apm.Libraries.Newtonsoft.Json.Linq.JsonPath 5 | { 6 | internal class QueryScanFilter : PathFilter 7 | { 8 | public QueryScanFilter(QueryExpression expression) => Expression = expression; 9 | 10 | internal QueryExpression Expression; 11 | 12 | public override IEnumerable ExecuteFilter(JToken root, IEnumerable current, JsonSelectSettings? settings) 13 | { 14 | foreach (var t in current) 15 | { 16 | if (t is JContainer c) 17 | { 18 | foreach (var d in c.DescendantsAndSelf()) 19 | { 20 | if (Expression.IsMatch(root, d, settings)) yield return d; 21 | } 22 | } 23 | else 24 | { 25 | if (Expression.IsMatch(root, t, settings)) yield return t; 26 | } 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /test/azure/Elastic.Apm.Azure.ServiceBus.Tests/Elastic.Apm.Azure.ServiceBus.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | false 6 | Elastic.Apm.Azure.ServiceBus.Tests 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /test/profiler/Elastic.Apm.Profiler.Managed.Tests/DuckTyping/Properties/ValueType/ProxiesDefinitions/IObscureStaticErrorDuckType.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under 2 | // one or more agreements. 3 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 4 | // See the LICENSE file in the project root for more information 5 | // 6 | // 7 | // Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. 8 | // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. 9 | // 10 | 11 | namespace Elastic.Apm.Profiler.Managed.Tests.DuckTyping.Properties.ValueType.ProxiesDefinitions 12 | { 13 | public interface IObscureStaticErrorDuckType 14 | { 15 | int PublicStaticGetValueType { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /test/profiler/applications/KafkaSample/SampleMessage.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under 2 | // one or more agreements. 3 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 4 | // See the LICENSE file in the project root for more information 5 | // 6 | // Based on Producer type in https://github.com/DataDog/dd-trace-dotnet/blob/master/tracer/test/test-applications/integrations/Samples.Kafka/Producer.cs#L107-L119 7 | // Licensed under Apache 2.0 8 | 9 | namespace KafkaSample 10 | { 11 | public class SampleMessage 12 | { 13 | public string Category { get; } 14 | public int MessageNumber { get; } 15 | public bool IsProducedAsync { get; } 16 | 17 | public SampleMessage(string category, int messageNumber, bool isProducedAsync) 18 | { 19 | Category = category; 20 | MessageNumber = messageNumber; 21 | IsProducedAsync = isProducedAsync; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/Elastic.Apm/Api/ProcessInformation.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under 2 | // one or more agreements. 3 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 4 | // See the LICENSE file in the project root for more information 5 | 6 | using System.Diagnostics; 7 | using Elastic.Apm.Api.Constraints; 8 | using Elastic.Apm.Helpers; 9 | 10 | namespace Elastic.Apm.Api; 11 | 12 | internal class ProcessInformation 13 | { 14 | public int Pid { get; set; } 15 | 16 | [MaxLength] 17 | public string Title { get; set; } 18 | 19 | public static ProcessInformation Create() 20 | { 21 | var p = Process.GetCurrentProcess(); 22 | return new ProcessInformation { Pid = p.Id, Title = p.ProcessName }; 23 | } 24 | 25 | public override string ToString() => new ToStringBuilder(nameof(Service)) 26 | { 27 | { nameof(Pid), Pid }, 28 | { nameof(Title), Title } 29 | }.ToString(); 30 | } 31 | -------------------------------------------------------------------------------- /src/azure/Elastic.Apm.Azure.CosmosDb/Elastic.Apm.Azure.CosmosDb.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | Elastic.Apm.Azure.CosmosDb 6 | Elastic.Apm.Azure.CosmosDb 7 | Elastic.Apm.Azure.CosmosDb 8 | Elastic APM for Azure Cosmos DB. This package contains auto instrumentation for Microsoft.Azure.Cosmos, 9 | Microsoft.Azure.DocumentDb, and Microsoft.Azure.DocumentDb.Core. 10 | apm, monitoring, elastic, elasticapm, analytics, azure, cosmos, cosmosdb, documentdb 11 | true 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /test/Elastic.Apm.Tests.Utilities/FlushingTextWriterToLineWriterAdaptor.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | using System.IO; 6 | using Elastic.Apm.Helpers; 7 | 8 | namespace Elastic.Apm.Tests.Utilities 9 | { 10 | public class FlushingTextWriterToLineWriterAdaptor : ILineWriter 11 | { 12 | private readonly string _prefix; 13 | private readonly TextWriter _textWriter; 14 | 15 | public FlushingTextWriterToLineWriterAdaptor(TextWriter textWriter, string prefix = "") 16 | { 17 | _textWriter = textWriter; 18 | _prefix = prefix; 19 | } 20 | 21 | public void WriteLine(string text) 22 | { 23 | _textWriter.WriteLine(TextUtils.PrefixEveryLine(text, _prefix)); 24 | _textWriter.Flush(); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/Elastic.Apm/Api/SpecificationAttribute.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under 2 | // one or more agreements. 3 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 4 | // See the LICENSE file in the project root for more information 5 | 6 | using System; 7 | 8 | namespace Elastic.Apm.Api 9 | { 10 | /// 11 | /// Defines the apm server specification that the type adheres to 12 | /// 13 | [AttributeUsage(AttributeTargets.Interface | AttributeTargets.Class)] 14 | public class SpecificationAttribute : Attribute 15 | { 16 | public SpecificationAttribute(string path) => Path = path; 17 | 18 | /// 19 | /// Path of the specification, relative to the apm-server directory 20 | /// 21 | /// 22 | /// The path also aligns with the APM server specification $id 23 | /// 24 | public string Path { get; } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Elastic.Apm/Libraries/Newtonsoft.Json/JsonNameTable.cs: -------------------------------------------------------------------------------- 1 | #nullable enable 2 | namespace Elastic.Apm.Libraries.Newtonsoft.Json 3 | { 4 | /// 5 | /// Base class for a table of atomized string objects. 6 | /// 7 | internal abstract class JsonNameTable 8 | { 9 | /// 10 | /// Gets a string containing the same characters as the specified range of characters in the given array. 11 | /// 12 | /// The character array containing the name to find. 13 | /// The zero-based index into the array specifying the first character of the name. 14 | /// The number of characters in the name. 15 | /// A string containing the same characters as the specified range of characters in the given array. 16 | public abstract string? Get(char[] key, int start, int length); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/Elastic.Apm/ServerInfo/IApmServerInfo.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under 2 | // one or more agreements. 3 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 4 | // See the LICENSE file in the project root for more information 5 | 6 | namespace Elastic.Apm.ServerInfo 7 | { 8 | /// 9 | /// Encapsulates information about the APM Server that receives data from the agent. 10 | /// 11 | internal interface IApmServerInfo 12 | { 13 | /// 14 | /// The version of the APM server. 15 | /// This can be null if the agent has not yet queried the APM server for its version or the query failed. 16 | /// The agent should not depend on the APM server version and if the version is not (yet) available the agent should 17 | /// default to a reasonable behaviour. 18 | /// 19 | ElasticVersion Version { get; set; } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /test/Elastic.Apm.Tests.Utilities/IntExtensions.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | using System; 6 | using System.Threading.Tasks; 7 | 8 | namespace Elastic.Apm.Tests.Utilities 9 | { 10 | public static class IntExtensions 11 | { 12 | public static void Repeat(this int repeatCount, Action action) 13 | { 14 | for (var i = 0; i < repeatCount; ++i) 15 | action(); 16 | } 17 | 18 | public static void Repeat(this int repeatCount, Action action) 19 | { 20 | for (var i = 0; i < repeatCount; ++i) 21 | action(i); 22 | } 23 | 24 | public static async Task Repeat(this int repeatCount, Func action) 25 | { 26 | for (var i = 0; i < repeatCount; ++i) 27 | await action(i); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /test/iis/Elastic.Apm.AspNetFullFramework.Tests/MetricsWithAccessToPerfCountersTests.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | using System.Threading.Tasks; 6 | using Xunit; 7 | using Xunit.Abstractions; 8 | 9 | namespace Elastic.Apm.AspNetFullFramework.Tests 10 | { 11 | [Collection(Consts.AspNetFullFrameworkTestsCollection)] 12 | public class MetricsWithAccessToPerfCountersTests : MetricsTestsBase 13 | { 14 | public MetricsWithAccessToPerfCountersTests(ITestOutputHelper xUnitOutputHelper) 15 | : base(xUnitOutputHelper, /* sampleAppShouldHaveAccessToPerfCounters: */ true) { } 16 | 17 | [AspNetFullFrameworkFact] 18 | public async Task VerifyMetricsBasicConstraints() => await VerifyMetricsBasicConstraintsImpl(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /test/instrumentations/grpc/GrpcClientSample/GrpcClientSample.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net8.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | Protos\greet.proto 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/Elastic.Apm/Helpers/ContractExtensions.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | using System; 6 | 7 | namespace Elastic.Apm.Helpers 8 | { 9 | internal static class ContractExtensions 10 | { 11 | public static T ThrowIfArgumentNull(this T arg, string argName) where T : class => 12 | arg ?? throw new ArgumentNullException(argName); 13 | 14 | public static T? ThrowIfNullableValueArgumentNull(this T? arg, string argName) where T : struct => 15 | arg ?? throw new ArgumentNullException(argName); 16 | 17 | public static int ThrowIfArgumentNegative(this int arg, string argName) => 18 | arg < 0 ? throw new ArgumentException($"Argument {argName} should not be negative but its value is {arg}", argName) : arg; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/Elastic.Apm/Helpers/ExceptionFilter.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | using System; 6 | using Elastic.Apm.Api; 7 | 8 | namespace Elastic.Apm.Helpers 9 | { 10 | /// 11 | /// Offers methods that can be used as exception filters. 12 | /// Within the filter we return false and capture the exception. 13 | /// Advantage: it avoid stack unwinding. 14 | /// 15 | internal static class ExceptionFilter 16 | { 17 | internal static bool Capture(Exception e, ITransaction transaction) 18 | { 19 | transaction.CaptureException(e); 20 | return false; 21 | } 22 | 23 | internal static bool Capture(Exception e, ISpan span) 24 | { 25 | span.CaptureException(e); 26 | return false; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/profiler/Elastic.Apm.Profiler.Managed/Reflection/OpCodeValues.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under the Apache 2.0 License. 2 | // Elasticsearch B.V licenses this file, including any modifications, to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information. 4 | // 5 | // 6 | // Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. 7 | // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. 8 | // 9 | 10 | namespace Elastic.Apm.Profiler.Managed.Reflection 11 | { 12 | internal enum OpCodeValue : short 13 | { 14 | /// 15 | Call = 40, 16 | 17 | /// 18 | Callvirt = 111 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /test/profiler/Elastic.Apm.Profiler.Managed.Tests/DuckTyping/Properties/ReferenceType/ProxiesDefinitions/IObscureStaticErrorDuckType.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under 2 | // one or more agreements. 3 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 4 | // See the LICENSE file in the project root for more information 5 | // 6 | // 7 | // Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. 8 | // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. 9 | // 10 | 11 | namespace Elastic.Apm.Profiler.Managed.Tests.DuckTyping.Properties.ReferenceType.ProxiesDefinitions 12 | { 13 | public interface IObscureStaticErrorDuckType 14 | { 15 | string PublicStaticGetReferenceType { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /test/profiler/Elastic.Apm.Profiler.Managed.Tests/DuckTyping/Properties/TypeChaining/ProxiesDefinitions/IObscureStaticErrorDuckType.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under 2 | // one or more agreements. 3 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 4 | // See the LICENSE file in the project root for more information 5 | // 6 | // 7 | // Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. 8 | // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. 9 | // 10 | 11 | namespace Elastic.Apm.Profiler.Managed.Tests.DuckTyping.Properties.TypeChaining.ProxiesDefinitions 12 | { 13 | public interface IObscureStaticErrorDuckType 14 | { 15 | IDummyFieldObject PublicStaticGetSelfType { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /test/iis/AspNetFullFrameworkSampleApp/ActionFilters/RedirectIfAuthenticatedAttribute.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under 2 | // one or more agreements. 3 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 4 | // See the LICENSE file in the project root for more information 5 | 6 | using System.Web.Mvc; 7 | 8 | namespace AspNetFullFrameworkSampleApp.ActionFilters 9 | { 10 | /// 11 | /// Redirects an authenticated user from an action intended for an unauthenticated user. 12 | /// 13 | public sealed class RedirectIfAuthenticatedAttribute : ActionFilterAttribute 14 | { 15 | public RedirectIfAuthenticatedAttribute() => Order = 1; 16 | 17 | public override void OnActionExecuting(ActionExecutingContext filterContext) 18 | { 19 | if (filterContext.HttpContext.Request.IsAuthenticated) 20 | filterContext.Result = new RedirectResult("~/"); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /test/iis/Elastic.Apm.AspNetFullFramework.Tests/MetricsWithoutAccessToPerfCountersTests.cs: -------------------------------------------------------------------------------- 1 | // Licensed to Elasticsearch B.V under one or more agreements. 2 | // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. 3 | // See the LICENSE file in the project root for more information 4 | 5 | using System.Threading.Tasks; 6 | using Xunit; 7 | using Xunit.Abstractions; 8 | 9 | namespace Elastic.Apm.AspNetFullFramework.Tests 10 | { 11 | [Collection(Consts.AspNetFullFrameworkTestsCollection)] 12 | public class MetricsWithoutAccessToPerfCountersTests : MetricsTestsBase 13 | { 14 | public MetricsWithoutAccessToPerfCountersTests(ITestOutputHelper xUnitOutputHelper) 15 | : base(xUnitOutputHelper, /* sampleAppShouldHaveAccessToPerfCounters: */ false) { } 16 | 17 | [AspNetFullFrameworkFact] 18 | public async Task VerifyMetricsBasicConstraints() => await VerifyMetricsBasicConstraintsImpl(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /test/instrumentations/Elastic.Apm.MongoDb.Tests/Fixture/IMongoConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Based on the elastic-apm-mongo project by Vadim Hatsura (@vhatsura) 2 | // https://github.com/vhatsura/elastic-apm-mongo 3 | // Licensed to Elasticsearch B.V under the Apache 2.0 License. 4 | // Elasticsearch B.V licenses this file, including any modifications, to you under the Apache 2.0 License. 5 | // See the LICENSE file in the project root for more information. 6 | 7 | using System.Threading.Tasks; 8 | using MongoDB.Driver; 9 | 10 | namespace Elastic.Apm.MongoDb.Tests.Fixture 11 | { 12 | public interface IMongoConfiguration 13 | { 14 | string DatabaseName { get; } 15 | 16 | string CollectionName { get; } 17 | MongoClient GetMongoClient(string connectionString); 18 | 19 | Task InitializeAsync(IMongoCollection collection); 20 | 21 | Task DisposeAsync(IMongoCollection collection); 22 | } 23 | } 24 | --------------------------------------------------------------------------------