Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions ElasticApmAgent.sln
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RabbitMqSample", "sample\Ra
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenTelemetrySample", "sample\OpenTelemetrySample\OpenTelemetrySample.csproj", "{3D31589A-CA44-4D6D-9944-26CE9640A283}"
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Npgsql6Common", "sample\Npgsql6Common\Npgsql6Common.shproj", "{42D8402D-19B0-4EC5-A347-919157DD29A4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Npgsql6Sample", "sample\Npgsql6Sample\Npgsql6Sample.csproj", "{58D8B98E-C52E-47F4-8DF2-3CBED2BDC490}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -471,6 +475,10 @@ Global
{3D31589A-CA44-4D6D-9944-26CE9640A283}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3D31589A-CA44-4D6D-9944-26CE9640A283}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3D31589A-CA44-4D6D-9944-26CE9640A283}.Release|Any CPU.Build.0 = Release|Any CPU
{58D8B98E-C52E-47F4-8DF2-3CBED2BDC490}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{58D8B98E-C52E-47F4-8DF2-3CBED2BDC490}.Debug|Any CPU.Build.0 = Debug|Any CPU
{58D8B98E-C52E-47F4-8DF2-3CBED2BDC490}.Release|Any CPU.ActiveCfg = Release|Any CPU
{58D8B98E-C52E-47F4-8DF2-3CBED2BDC490}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -547,6 +555,8 @@ Global
{2B23487A-B340-4F5C-A49B-9B829F437A5A} = {3C791D9C-6F19-4F46-B367-2EC0F818762D}
{1D6B0C67-42C8-4AB4-A795-B6FF8EF7196E} = {3C791D9C-6F19-4F46-B367-2EC0F818762D}
{3D31589A-CA44-4D6D-9944-26CE9640A283} = {3C791D9C-6F19-4F46-B367-2EC0F818762D}
{42D8402D-19B0-4EC5-A347-919157DD29A4} = {3C791D9C-6F19-4F46-B367-2EC0F818762D}
{58D8B98E-C52E-47F4-8DF2-3CBED2BDC490} = {3C791D9C-6F19-4F46-B367-2EC0F818762D}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {69E02FD9-C9DE-412C-AB6B-5B8BECC6BFA5}
Expand Down
4 changes: 2 additions & 2 deletions docs/integrations.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
|MySql.Data 6.7.0 - 8.{star}.{star}

.1+.^|NpgsqlCommand
|{nuget}/Npgsql[Npgsql 4.0.0 - 5.{star}.{star}]
|Npgsql 4.0.0 - 5.{star}.{star}
|{nuget}/Npgsql[Npgsql 4.0.0 - 6.{star}.{star}]
|Npgsql 4.0.0 - 6.{star}.{star}

.2+.^|OracleCommand
|{nuget}/Oracle.ManagedDataAccess[Oracle.ManagedDataAccess 12.2.1100 - 21.{star}.{star}]
Expand Down
15 changes: 15 additions & 0 deletions sample/Npgsql6Common/Npgsql6Common.projitems
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
<HasSharedItems>true</HasSharedItems>
<SharedGUID>A010E94E-B957-4E9C-AC94-A05ED41D39D9</SharedGUID>
</PropertyGroup>
<PropertyGroup Label="Configuration">
<Import_RootNamespace>Npgsql6Common</Import_RootNamespace>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)NpgsqlCommandExecutor.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Program.cs" />
</ItemGroup>
</Project>
11 changes: 11 additions & 0 deletions sample/Npgsql6Common/Npgsql6Common.shproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals">
<ProjectGuid>{42D8402D-19B0-4EC5-A347-919157DD29A4}</ProjectGuid>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props" />
<Import Project="Npgsql6Common.projitems" Label="Shared" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets" />
</Project>
Original file line number Diff line number Diff line change
@@ -1,65 +1,65 @@
// Based on .NET Tracer for Datadog APM by Datadog
// https://github.com/DataDog/dd-trace-dotnet
// Licensed to Elasticsearch B.V under
// one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
using System.Data;
using System.Data.Common;
using System.Threading;
using System.Threading.Tasks;
using Elastic.Apm.AdoNet.NetStandard;
using Npgsql;
namespace NpgsqlSample
{
public class NpgsqlCommandExecutor : DbCommandExecutor<NpgsqlCommand>
{
public override string CommandTypeName => nameof(NpgsqlCommand);
public override bool SupportsAsyncMethods => true;
public override void ExecuteNonQuery(NpgsqlCommand command) => command.ExecuteNonQuery();
public override Task ExecuteNonQueryAsync(NpgsqlCommand command) => command.ExecuteNonQueryAsync();
public override Task ExecuteNonQueryAsync(NpgsqlCommand command, CancellationToken cancellationToken) => command.ExecuteNonQueryAsync(cancellationToken);
public override void ExecuteScalar(NpgsqlCommand command) => command.ExecuteScalar();
public override Task ExecuteScalarAsync(NpgsqlCommand command) => command.ExecuteScalarAsync();
public override Task ExecuteScalarAsync(NpgsqlCommand command, CancellationToken cancellationToken) => command.ExecuteScalarAsync(cancellationToken);
public override void ExecuteReader(NpgsqlCommand command)
{
using DbDataReader reader = command.ExecuteReader();
}
public override void ExecuteReader(NpgsqlCommand command, CommandBehavior behavior)
{
using DbDataReader reader = command.ExecuteReader(behavior);
}
public override async Task ExecuteReaderAsync(NpgsqlCommand command)
{
using DbDataReader reader = await command.ExecuteReaderAsync();
}
public override async Task ExecuteReaderAsync(NpgsqlCommand command, CommandBehavior behavior)
{
using DbDataReader reader = await command.ExecuteReaderAsync(behavior);
}
public override async Task ExecuteReaderAsync(NpgsqlCommand command, CancellationToken cancellationToken)
{
using DbDataReader reader = await command.ExecuteReaderAsync(cancellationToken);
}
public override async Task ExecuteReaderAsync(NpgsqlCommand command, CommandBehavior behavior, CancellationToken cancellationToken)
{
using DbDataReader reader = await command.ExecuteReaderAsync(behavior, cancellationToken);
}
}
}
// Based on .NET Tracer for Datadog APM by Datadog
// https://github.com/DataDog/dd-trace-dotnet
// Licensed to Elasticsearch B.V under
// one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information

using System.Data;
using System.Data.Common;
using System.Threading;
using System.Threading.Tasks;
using Elastic.Apm.AdoNet.NetStandard;
using Npgsql;

namespace NpgsqlSample
{
public class NpgsqlCommandExecutor : DbCommandExecutor<NpgsqlCommand>
{
public override string CommandTypeName => nameof(NpgsqlCommand);

public override bool SupportsAsyncMethods => true;

public override void ExecuteNonQuery(NpgsqlCommand command) => command.ExecuteNonQuery();

public override Task ExecuteNonQueryAsync(NpgsqlCommand command) => command.ExecuteNonQueryAsync();

public override Task ExecuteNonQueryAsync(NpgsqlCommand command, CancellationToken cancellationToken) => command.ExecuteNonQueryAsync(cancellationToken);

public override void ExecuteScalar(NpgsqlCommand command) => command.ExecuteScalar();

public override Task ExecuteScalarAsync(NpgsqlCommand command) => command.ExecuteScalarAsync();

public override Task ExecuteScalarAsync(NpgsqlCommand command, CancellationToken cancellationToken) => command.ExecuteScalarAsync(cancellationToken);

public override void ExecuteReader(NpgsqlCommand command)
{
using DbDataReader reader = command.ExecuteReader();
}

public override void ExecuteReader(NpgsqlCommand command, CommandBehavior behavior)
{
using DbDataReader reader = command.ExecuteReader(behavior);
}

public override async Task ExecuteReaderAsync(NpgsqlCommand command)
{
using DbDataReader reader = await command.ExecuteReaderAsync();
}

public override async Task ExecuteReaderAsync(NpgsqlCommand command, CommandBehavior behavior)
{
using DbDataReader reader = await command.ExecuteReaderAsync(behavior);
}

public override async Task ExecuteReaderAsync(NpgsqlCommand command, CancellationToken cancellationToken)
{
using DbDataReader reader = await command.ExecuteReaderAsync(cancellationToken);
}

public override async Task ExecuteReaderAsync(NpgsqlCommand command, CommandBehavior behavior, CancellationToken cancellationToken)
{
using DbDataReader reader = await command.ExecuteReaderAsync(behavior, cancellationToken);
}
}
}
126 changes: 63 additions & 63 deletions sample/NpgsqlSample/Program.cs → sample/Npgsql6Common/Program.cs
Original file line number Diff line number Diff line change
@@ -1,63 +1,63 @@
// Licensed to Elasticsearch B.V under
// one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
using System;
using System.Data.Common;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using Elastic.Apm.AdoNet;
using Npgsql;
namespace NpgsqlSample
{
internal static class Program
{
private static async Task<int> Main(string[] args)
{
var cancellationTokenSource = new CancellationTokenSource();
var connectionType = typeof(NpgsqlConnection);
var guid = Guid.NewGuid().ToString("N");
Console.WriteLine($"Run commands ({guid})");
using (var connection = CreateAndOpenConnection(connectionType))
{
var dbCommandFactory = new DbCommandFactory(connection, $"\"npgsql_all_{guid}\"");
await DbCommandRunner.RunAllAsync<NpgsqlCommand>(
dbCommandFactory,
new NpgsqlCommandExecutor(),
cancellationTokenSource.Token);
}
var npgsqlAssembly = Assembly.LoadFile(connectionType.Assembly.Location);
var npgsqlConnection = npgsqlAssembly.GetType(connectionType.FullName);
using (var connection = CreateAndOpenConnection(npgsqlConnection))
{
var dbCommandFactory = new DbCommandFactory(connection, $"\"npgsql_basetypes_{guid}\"");
await DbCommandRunner.RunBaseTypesAsync(
dbCommandFactory,
cancellationTokenSource.Token);
}
Console.WriteLine("Finished sending commands");
// allow the agent time to send the spans
await Task.Delay(TimeSpan.FromSeconds(40), cancellationTokenSource.Token);
return 0;
}
private static DbConnection CreateAndOpenConnection(Type connectionType)
{
var connectionString = Environment.GetEnvironmentVariable("POSTGRES_CONNECTION_STRING");
var connection = Activator.CreateInstance(connectionType, connectionString) as DbConnection;
connection.Open();
return connection;
}
}
}
// Licensed to Elasticsearch B.V under
// one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information

using System;
using System.Data.Common;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using Elastic.Apm.AdoNet;
using Npgsql;

namespace NpgsqlSample
{
internal static class Program
{
private static async Task<int> Main(string[] args)
{
var cancellationTokenSource = new CancellationTokenSource();
var connectionType = typeof(NpgsqlConnection);
var guid = Guid.NewGuid().ToString("N");

Console.WriteLine($"Run commands ({guid})");

using (var connection = CreateAndOpenConnection(connectionType))
{
var dbCommandFactory = new DbCommandFactory(connection, $"\"npgsql_all_{guid}\"");

await DbCommandRunner.RunAllAsync<NpgsqlCommand>(
dbCommandFactory,
new NpgsqlCommandExecutor(),
cancellationTokenSource.Token);
}

var npgsqlAssembly = Assembly.LoadFile(connectionType.Assembly.Location);
var npgsqlConnection = npgsqlAssembly.GetType(connectionType.FullName);

using (var connection = CreateAndOpenConnection(npgsqlConnection))
{
var dbCommandFactory = new DbCommandFactory(connection, $"\"npgsql_basetypes_{guid}\"");

await DbCommandRunner.RunBaseTypesAsync(
dbCommandFactory,
cancellationTokenSource.Token);
}

Console.WriteLine("Finished sending commands");

// allow the agent time to send the spans
await Task.Delay(TimeSpan.FromSeconds(40), cancellationTokenSource.Token);
return 0;
}

private static DbConnection CreateAndOpenConnection(Type connectionType)
{
var connectionString = Environment.GetEnvironmentVariable("POSTGRES_CONNECTION_STRING");
var connection = Activator.CreateInstance(connectionType, connectionString) as DbConnection;
connection.Open();
return connection;
}
}
}
19 changes: 19 additions & 0 deletions sample/Npgsql6Sample/Npgsql6Sample.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<NpgsqlVersion Condition="'$(NpgsqlVersion)'==''">6.0.0</NpgsqlVersion>
<OutputType>Exe</OutputType>
<TargetFrameworks>net461;netcoreapp3.1;net5.0;</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Npgsql" Version="$(NpgsqlVersion)" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Elastic.Apm.AdoNet\Elastic.Apm.AdoNet.csproj" />
</ItemGroup>

<Import Project="..\Npgsql6Common\Npgsql6Common.projitems" Label="Shared" />

</Project>
2 changes: 2 additions & 0 deletions sample/NpgsqlSample/NpgsqlSample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@
<ProjectReference Include="..\Elastic.Apm.AdoNet\Elastic.Apm.AdoNet.csproj" />
</ItemGroup>

<Import Project="..\Npgsql6Common\Npgsql6Common.projitems" Label="Shared" />

</Project>
Loading