Skip to content
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

Export-DbaXeCsv, fix path handling #6870

Merged
merged 1 commit into from
Sep 22, 2020

Conversation

niphlod
Copy link
Contributor

@niphlod niphlod commented Sep 21, 2020

Type of Change

  • Bug fix (non-breaking change, fixes [Bug] Get-DbaXESession - Issue finding path for rollover files #6861 )
  • New feature (non-breaking change, adds functionality, fixes # )
  • Breaking change (effects multiple commands or functionality, fixes # )
  • Ran manual Pester test and has passed (`.\tests\manual.pester.ps1)
  • Adding code coverage to existing functionality
  • Pester test is included
  • If new file reference added for test, has is been added to github.com/sqlcollaborative/appveyor-lab ?
  • Nunit test is included
  • Documentation
  • Build system

Purpose

Make sure to target the correct xel files in all cases, I added a comment.
$outDir sounded like a leftover, so I removed it. Also, changed extension to csv rather than .sql.

Approach

Irregardless of the format of the "filename" attribute, .xel files are always transformed. Ideally we should not just check filename but also 'max_file_size','max_rollover_files'. The point is that it seems sufficient to have the filename to be able to build the final path, which is always a "mask" of the filename because MSSQL appends _x_yyyyyyyyy to the BASENAME of the specified filename.
This means filename = 'niphlod' ends up with niphlod_x_yyyyyyy.xel but the same happens when filename = niphlod.xel.
In any case this modification sets the path of Get-ChildItem to return even niphlod.xel, if found, so if someone falls into that cornercase (which, by my experience, is impossible) it remains covered too.

To confirm watch at system_health default trace....a better sum up can be retrieved with

SELECT s.name as session_name, f.name as param, f.value as param_value
FROM 
 sys.server_event_session_fields AS f
INNER JOIN
 sys.server_event_sessions AS s
ON
 f.event_session_id = s.event_session_id
WHERE f.name IN ('max_file_size','max_rollover_files', 'filename')
AND s.name = 'system_health'
ORDER BY s.name

Same thing can be retrieved by

$xesession = Get-DbaXESession -SqlInstance your_instance -Session system_health
$xesession.Targets.TargetFields | Where-Object Name -in filename,max_file_size,max_rollover_files | Select-Object Name, Value

As this is one of @spaghettidba and @potatoqualitee babies, I'm totally waiting for their approval :D

@potatoqualitee
Copy link
Member

I love this change, thank you so much! 🍝 did the C# and I did the PS, so I'll go ahead and approve this.

@potatoqualitee potatoqualitee merged commit a3c587d into dataplat:development Sep 22, 2020
@spaghettidba
Copy link
Contributor

Awesome stuff Simone! Thanks for contributing!

@niphlod niphlod deleted the fix/6861 branch September 23, 2020 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] Get-DbaXESession - Issue finding path for rollover files
3 participants