-
Notifications
You must be signed in to change notification settings - Fork 197
Added support for controlling the op_type when indexing #356
Added support for controlling the op_type when indexing #356
Conversation
Thanks for this PR. Looks good. I agree with your points, the exception type does not look like an issue, the other one might be an issue. But that we can highlight in the changes.md and readme.md. |
@mivano currently there's an issue with the error handling since when we're setting the The question is would we like to stay with the DynamicResponse or are we open to de-serialize the response to DTO:s instead? |
src/Serilog.Sinks.Elasticsearch/Sinks/ElasticSearch/ElasticsearchSinkState.cs
Show resolved
Hide resolved
src/Serilog.Sinks.Elasticsearch/LoggerConfigurationElasticSearchExtensions.cs
Show resolved
Hide resolved
src/Serilog.Sinks.Elasticsearch/Sinks/ElasticSearch/ElasticSearchSink.cs
Show resolved
Hide resolved
src/Serilog.Sinks.Elasticsearch/LoggerConfigurationElasticSearchExtensions.cs
Show resolved
Hide resolved
Another thing that crossed my mind; the durable part also sends data to ES in a similar manner, but using different code constructs. Most likely the same issue will apply here. For some while now I feel less comfortable with this durable part. It is a large part of the code base with a lot of duplication. And that last part makes introducing these changes more difficult. Besides, the durable functionality is not as stable as it should be and there might be better solutions if you want similar behaviour. What is your take on this? Worthwhile to apply the same thing to the durable part, exclude it explicitly or something else? |
I did a quick fix for the durable part and there are 2 places that needs to be fixed, so I'll fix that as well. |
A totally separate discussion of course from this PR, but I would be inclined to remove it out of this sink and offer functionality in a different way. Preferable using a higher abstraction, so you can specify it on the serilog sinks level instead. This original implementation came from the Seq one (https://github.com/serilog/serilog-sinks-seq/tree/dev/src/Serilog.Sinks.Seq/Sinks/Seq/Durable) so there are more sinks with a similar feature. Problem is that I do not know how many users are actually depending on this durable feature. So it would be a real breaking change with or without another solution. |
In order to write to data streams we'll need to set the op_type to create the default is index In order to don't serialize null values for the batch action and to not depend on custom serialization setting we're using LowLevelRequestResponseSerializer.Instance for serialization of the action. We won't throw exception when setting the TypeName to null since: - This is deprecated in v7 - Won't work in v8
In order to be able to use templates and at the same time remove the doc type we shouldn't override it if it's set to null.
Use the same logic for creating bulk action within the durable sink as in the standard sink.
4131406
to
eeb0a02
Compare
Merging it into dev so we have a prerelease package. |
Fixes a regression introduced in serilog-contrib#356 We should override the TypeName if it's specified. Note that there are different defaults depending on how the options are created. - Created from configuration it defaults to `logevent` - Created from code it defaults to `_doc`
Fixes a regression introduced in #356 We should override the TypeName if it's specified. Note that there are different defaults depending on how the options are created. - Created from configuration it defaults to `logevent` - Created from code it defaults to `_doc`
In order to write to data streams we'll need to set the
op_type
tocreate
the default isindex
In order to don't serialize null values for the batch action and to not depend
on custom serialization setting we're using
LowLevelRequestResponseSerializer.Instance
for serialization of the action.
We won't throw exception when setting the TypeName to null since:
What issue does this PR address?
BatchAction
toElasticOpType.Create
TypeName
tonull
to remove it from the payload being sent to Elastic.Does this PR introduce a breaking change?
I don't think we have introduced an breaking change but we'll need to review the following changes to make sure they're not breaking.
The custom serializer for the action has been replaced by a specific one, it's not impossible that someone has been intercepting this call for adding custom elements when logging.
https://github.com/serilog/serilog-sinks-elasticsearch/pull/356/files#diff-15ec7bbc1a4d48125fae012ffb1896acR191
Earlier and exception was thrown when trying to set the
TypeName
tonull
it's unlikely that someone has relied on this exception. https://github.com/serilog/serilog-sinks-elasticsearch/pull/356/files#diff-cb61ceb2dfe8091b1abe76e3c275d6d0L77Please check if the PR fulfills these requirements
Other information: