-
Notifications
You must be signed in to change notification settings - Fork 772
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor exporter - step 1 #1078
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// <copyright file="ActivityExporterSync.cs" company="OpenTelemetry Authors"> | ||
// Copyright The OpenTelemetry Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// </copyright> | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace OpenTelemetry.Trace | ||
{ | ||
/// <summary> | ||
/// Enumeration used to define the result of an export operation. | ||
/// </summary> | ||
public enum ExportResultSync | ||
{ | ||
/// <summary> | ||
/// Batch is successfully exported. | ||
/// </summary> | ||
Succeeded = 0, | ||
|
||
/// <summary> | ||
/// Batch export failed. | ||
/// </summary> | ||
Failed = 1, | ||
} | ||
|
||
/// <summary> | ||
/// ActivityExporterSync base class. | ||
/// </summary> | ||
public abstract class ActivityExporterSync : IDisposable | ||
{ | ||
/// <summary> | ||
/// Exports batch of activities. | ||
/// </summary> | ||
/// <param name="batch">Batch of activities to export.</param> | ||
/// <returns>Result of export.</returns> | ||
public abstract ExportResult Export(IEnumerable<Activity> batch); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❤️ this! Just got this merged so we can prevent allocations doing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. #1080 for tracking. |
||
|
||
/// <summary> | ||
/// Shuts down the exporter. | ||
/// </summary> | ||
public virtual void Shutdown() | ||
{ | ||
} | ||
|
||
/// <inheritdoc/> | ||
public void Dispose() | ||
{ | ||
this.Dispose(true); | ||
GC.SuppressFinalize(this); | ||
} | ||
|
||
/// <summary> | ||
/// Releases the unmanaged resources used by this class and optionally releases the managed resources. | ||
/// </summary> | ||
/// <param name="disposing"><see langword="true"/> to release both managed and unmanaged resources; <see langword="false"/> to release only unmanaged resources.</param> | ||
protected virtual void Dispose(bool disposing) | ||
{ | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we simply use a bool to indicate success/failure?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we want to keep close to the spec.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now I wonder why spec didn't simply use a boolean? I guess its leftover from old behavior where ExportResult had more than 2 possible values!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it leaves the room so in the future folks can add more value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mm.. Is there any value in Export() returning anything at all? I mean, irrespective of the return value, the Processor simply moves on to next batch. Is it to let Processor do some logging that batch is being dropped? Or to allow future possibilities..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see BIG value, but I do see value - for example - the processor could log an internal error, or the processor can use this indication to report exporting statistics (e.g. metrics telling folks how many activities are exported successfully vs. dropped).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are definitely interesting use cases, but seems to me to be more of a concern for the exporter itself since it has the underlying knowledge of either the error or statistics.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok. lets stick with spec and keep enum with 2 values for now :)